ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
## 修改数据(同步操作) ~~~ import Vue from 'vue' import Vuex from 'vuex' Vue.use(Vuex) export default new Vuex.Store({ state: { cont: 0 }, mutations: { add (state) { state.cont++ }, addn (state, num: number) { state.cont += num } }, actions: { }, modules: { } }) ~~~ ####1 修改数据 ~~~ this.$store.commit('add') this.$store.commit('addn',10) ~~~ ### 2 修改数据 ~~~ import { mapState, mapMutations } from 'vuex' methods: { ...mapMutations(['jian']), jianfa () { this.jian(3) } } ~~~