vuex取值和存值

store.js 文件中:

state:{
    
    
	value:''
}

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

.vue 文件:

// 存
this.$store.commit('changeValue',1)
// 取
console.log(this.$store.state.value)

猜你喜欢

转载自blog.csdn.net/weixin_35773751/article/details/104665855#comments_22041698