3

状态管理直接使用

this.$store.commit("SET_NAME", "okok");

存值时报错: [vuex] unknown mutation type: xxx

image

因为状态管理是分模块写的

image

所以在调用模块里的方法时,要在方法名前加上模块名,例如:

this.$store.commit("user/SET_NAME", "okok");

试一下

image

console

image

image


amao
34 声望3 粉丝

不学无术的大三狗一只