看了vuex會取值,但是不會存值,大佬能給個小demo學習一下,謝謝啦
1 回答

眼眸繁星
TA貢獻1873條經驗 獲得超9個贊
store.js:
state:{
value:''
}
mutations:{
changeValue(state,newVal){ state.value=newVal }
}
.vue:
//存this.$store.commit('changeValue',1)//取console.log(this.$store.state.value)//1
添加回答
舉報
0/150
提交
取消