2 回答

慕勒3428872
TA貢獻(xiàn)1848條經(jīng)驗(yàn) 獲得超6個(gè)贊
getter
寫在模塊里面
const moduleA = {
state: { ... },
mutations: { ... },
actions: { ... },
getters: { ... }
}
const moduleB = {
state: { ... },
mutations: { ... },
actions: { ... }
}
const store = new Vuex.Store({
modules: {
a: moduleA,
b: moduleB
}
})
store.state.a // -> moduleA 的狀態(tài)
store.state.b // -> moduleB 的狀態(tài)

呼如林
TA貢獻(xiàn)1798條經(jīng)驗(yàn) 獲得超3個(gè)贊
vuex模塊內(nèi)部的 action、mutation、和 getter 默認(rèn)是注冊在全局命名空間
中文的文檔沒更新,英文文檔已經(jīng)介紹了namspaced屬性了,應(yīng)該是從2.1.0版本開始支持
這個(gè)issue又介紹了以后的namespace屬性
添加回答
舉報(bào)
0/150
提交
取消