//store 中 store.js import Vue from 'vue' import Vuex from 'vuex' Vue.use(Vuex) const store = new Vuex.Store({ state: { author: 'Youngmon' }, mutations: { author(state, newName) { state.author = newName; } }, actions: { } }) export default store /** //main.js 新增 import store from './store' Vue.prototype.$store = store //demo.vue this.$store.commit("author","yongmao"); computed: { author() { return this.$store.state.author } } */