javascript – Probleme mit dem ES7-Abruf zum Abrufen von Daten
typecho
typecho 2017-06-26 10:50:50
0
3
751
fetch('/static/data/data.json')
            .then(data => {
                console.log(data);
            })

Aber die Daten wurden mir nicht zurückgegeben.

typecho
typecho

Following the voice in heart.

Antworte allen(3)
迷茫

首先 Fetch API 是一个 Web API,跟 ES7 没什么关系。

关于 Fetch API,需要配合 Request 和 Response 两个,关于这些 API 如何配合完成请求,这里有比较详细的教程。

女神的闺蜜爱上我

参见MDN:
https://developer.mozilla.org...进行_fetch_请求
应该使用:

data.blob()
学霸

fetch('/static/data/data.json')

        .then(data =>data.json())
        .then(json=>console.log(json))
Neueste Downloads
Mehr>
Web-Effekte
Quellcode der Website
Website-Materialien
Frontend-Vorlage