vuex取值和存值

store.js 文件中:

state:{
	value:''
}

mutations:{
	changeValue(){
		state.value = newVal
	}
}

.vue 文件:

// 存
this.$store.commit('changeValue',1)
// 取
console.log(this.$store.state.value)
posted @ 2022-12-06 22:19  轻风细雨_林木木  阅读(33)  评论(0编辑  收藏  举报