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);
有人能解释一下我做错了什么,或者是否有更好的方法来做到这一点?提前感谢
尝试:
var information = data[0].name;
你有一个对象数组,所以上面应该可以工作。