> ## 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)
`
```