已分配给计算属性“xxx”,但它没有设置方法
问题v-model值问题Vuex-Computedproperty“xxx”wasassignedtobutithasnosettererrorreporting123
Solution//在你的Componentcomputed:{...mapGetters({nameFromStore:'name'}),name:{get(){returnthis.nameFromStore},set(newName){returnnewName}}}//在你的storeexportconststore=newVuex.Store({state:{name:"stackoverflow"},getters:{name:(state)=>{returnstate.name;}}}我的解决方案组件页面
123 store下的common.jsconststate={checkStatus:false}constgetters={}constactions={}constmutations={setCheckStatus(state,payload){state.checkStatus=payload}}exportdefault{state,getters,actions,mutations}其他组件页面实时监听checkStatusimport{mapState}from"vuex"exportdefault{computed:{...mapState({checkStatus:state=>state.common.checkStatus}),},//watch实时监听checkStatuswatch:{checkStatus(newVal){if(newVal){}else{}}}}其他组件页面更新checkStatusimport{mapState}from"vuex"exportdefault{methods:{clickOpen(){this.$store.commit("setCheckStatus",true)},clickClose(){this.$store.commit("setCheckStatus",false)}}}bug:Vuex-已将计算属性“name”分配给但它没有setter