我在car模塊中自己的定義了state, getters,this.$store.state.car.list可以拿到值.但是,this.$store.state.car.carGetter報錯,請問.如何在組件中調用這個getters,//car.jsstate = {
list: []
}
getters = {
carGetter: state => {
return state.list.filter('');
}
}
new Vuex.Store({
getters: {
test: state => {
return '02';
}
},
modules: { car }
})
// 組件
this.$store.state.car.list // OK
this.$store.state.car.carGetter // undefined
this.$store.state.carGetter // 為什么這么用ok, 難道會把模塊中的getters注冊到root ?已解決模塊內部的 action、mutation、和 getter 現在仍然注冊在全局命名空間——這樣保證了多個模塊能夠響應同一 mutation 或 action。
添加回答
舉報
0/150
提交
取消