main.js import Vue from 'vue' import Vuex from 'vuex' Vue.use(Vuex) export default new Vuex.Store({ // data state: { count: 0, msg: 'hello world', num: 11, val: 12 }, // methods 外部用 this.$store.commit调用 mutations: { addNum(state) { state.count++ }, setNum(state