在做三级联动菜单页面的时候,之前的几个报错都解决了,终于没有报错了,控制台干干净净,最后菜单却没显示出来,用vue开发者工具一看,三级联动的模块里,计算属性显示undefined。
在计算属性里console了一下,数组什么的都能在控制台输出,发现数据明明是传过来了的,
尴尬,原来是搞各种bug,console来console去的把计算属性的return整没了。
computed:{
...mapState({
categoryList:(state)=>{
// console.log(state.home.categoryList)
state.home.categoryList
}
})
}
加上return就恢复了。
computed:{
...mapState({
//state的括号可以去掉,函数的大括号可以去掉
categoryList:(state)=>{
// console.log(state.home.categoryList);
return state.home.categoryList;
}
})
}
nice,我是伞兵。