> ## 1,vuex ``` index.js 用来暴露 ` import Vue from'vue' import Vuex from 'vuex' Vue.use(Vuex) conststore = newVuex.Store({ modules: { app, }, getters }) export default store ` getters.js 用来定义值 ` constgetters = { sidebar:state=>state.app.sidebar, } export default getters ` app.js 用来写函数 ` const app = { state: { once: '' " }, mutations: { SET_ONCE: (state, value) => { state.once= value } }, actions: { setOnce({ commit }){ commit('SET_ONCE', value) } } } export default app ` index.vue 调用方法 ` this.$store.dispatch('setLanguage', lang) ` ```