问题遇到的现象和发生背景
data() {
return {
chartInstance: null,
allData: null, // 服务器返回的数据
}
},
mounted() {
this.getData()
},
methods: {
getData() {
let vue = this
// http://127.0.0.1:80000/seller
const ret = this.$http.get('seller/',{
params:{"table":"civil_2022"}
})
.then((response)=>{
// console.log(response.data)
this.allData = response.data
})
.catch(function(error) {
console.log(error);
});
console.log(this)
}
}
最后一行打印的结果 能看到allData的值
但是console.log(this.allData)的时候结果却为null