Vue 中 axios 的回调函数 .then 里的this不指向vue实例解决办法
//在.then中使用箭头函数
var sub = new Vue({
el:"#app",
data:{
messg:""
},
methods:{
show:function(){
axios.get("cs.json")
.then((response)=>{
this.messg = response;
console.log(response);
})
.catch(function(error){
console.log(error);
})
}
},
mounted:function(){
this.$nextTick(function () {
this.show()
})
}
})
this 指向vue 实例