在mounted周期中,使用data中的属性没有数据。
getList() {
const param = {
id: this.listQuert.id
};
api.workinfo(param).then(response => {
const data = response.data;
this.list=data
console.log(this.list)
});
}
从api里面获取到了数据并存在this.list属性中,
mounted() {
console.log(this.list)
},
想在mounted中使用this.list数据,打印出来的是个默认的null值
如果想在mounted中使用this.list需要怎么写,谢谢
可以直接在getList的then方法中打印,
倘若非要在mounted()中使用的话可以呀试下下面这种写法: