APP.vue-----------------------
<template v-if="navShow==-1">
<Navigation></Navigation>
</template>
computed: {
navShow(){
return this.$store.getters.navShow
}
}
store.js-------------------
state: {
navShow: null ,//导航是否显示
}
mutations: {
navShowNo(state){
state.navShow= -1; //-1为不显示导航
}
}
getters: {
navShow: state => {
return state.navShow
}
}
actions: {
navShowNo ({commit}) {
commit('navShowNo');
}
}
wx.vue-------------
created(){
this.$store.dispatch("navShowNo");
//console.log(1)
console.log(this.$store.state.navShow)
}
this.$store.state.navShow中的值确实变了,但是菜单还是不隐藏
v-if='navShow == -1'
这个判断不是为true吗?
为true当然不隐藏啊