computed:{
...mapState({
categoryList:state=>state.home.homeData
})
},
mounted() {
console.log(this.categoryList); //错误示例!不应该在mounted中直接读,此时请求还没有完成。
},
watch:{
categoryList(value){
console.log(value); //正确用法!数据发生了变动,说明数据请求成功了
}
}