axios.post('/colrank/',{
}).then(function (response) {
this.data1=response.data;
console.log(this.data1);
})
.catch(function (error) {
console.log(error);
});
可以正常显示的,修改一下代码:
var that = this;
axios.post('/colrank/',{
}).then(function (response) {
that.data1=response.data;
console.log(that.data1);
})
.catch(function (error) {
console.log(error);
});
this指向
function 函数默认this指向是 windows
要么改成箭头函数
要么 重新声明一下
axios.post('/colrank/',{
}).then((response)=> {
this.data1=response.data;
console.log(this.data1);
})
.catch((error)=> {
console.log(error);
});
as
const that = this
axios.post('/colrank/',{
}).then(function (response) {
that.data1=response.data;
console.log(that.data1);
})
.catch(function (error) {
console.log(error);
})
您好,我是有问必答小助手,您的问题已经有小伙伴帮您解答,感谢您对有问必答的支持与关注!