【发布时间】:2021-11-03 21:10:21
【问题描述】:
JSON 文件 (Hello.json) 示例:
[
{
"Name": "Alex Smith",
"User": "1234",
"Description": "Blue eyes"
},
{
这就是我所拥有的:
fetch('Hello.json')
.then(function (response) {
return response.json();
})
.then(function (data) {
var information = data.name[0];
$('#information').append(information);
有人可以解释我做错了什么,或者是否有更好的方法来做到这一点?提前致谢
【问题讨论】:
-
data是一个包含对象的列表。您需要先导航到该对象。data[0].name代替data.name[0]
标签: javascript json file parent