美文网首页vue
Fetch Error: TypeError: Cannot

Fetch Error: TypeError: Cannot

作者: 月未雪 | 来源:发表于2019-11-22 10:00 被阅读0次

Fetch Error: TypeError: Cannot set property 'info' of undefined
at eval (VM532 HelloWorld.vue:134)

fetch('https://api.coindesk.com/v1/bpi/currentprice.json')
.then(function(response) {
return response.json();
})
.then(function(data) {
console.log('data', data);
this.info=data;

})
.then((data)=>{
this.info=data;
})
.catch(function(error) {
console.log('Fetch Error: ', error);
});

function(data){ } 与(data)=>{} 作用域不一样 ,所以要this.info绑定数据(data)=>{} 写法

相关文章

网友评论

    本文标题:Fetch Error: TypeError: Cannot

    本文链接:https://www.haomeiwen.com/subject/mrqxwctx.html