import pano from './module/pano'export const store = new Vuex.Store({
modules: {
pano
}
})
// pano.jsconst state = {
pano: null}
此時,獲取state的時候是this.$store.state.pano.pano.xxx,如何才能去除一層pano?目前其中一個方法是在pano.js里,如下這樣書寫,但是我的字段太多了// pano.jsconst state = { key1: '', key2: ''}還是用for in遍歷?// pano.jsconst state = {}const mutations = { updatePano: (state, payload) => { for (const key in payload) { state[key] = payload[key] } }}
vuex namespaced
慕的地6264312
2019-03-01 16:57:17