一:store/index文件state{}内,新增参数testObj:{name:'小哈'}
二:在store/index文件mutations{}内,定义修改事件
三:事件内的 [types.TEST_OBJ]是在mutatin-types内定义
四:页面使用
①:先引入 import { mapState, mapMutations } from "vuex";
②: computed: {
...mapState(['testObj']),
},
③:页面直接使用state参数:{{testObj.age}}
④:修改值
引入...mapMutations(["TEST_OBJ"]),
⑤:this.TEST_OBJ({age:15}) 修改了