亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

vue 組件如何調用 vuex 模塊中的getters

vue 組件如何調用 vuex 模塊中的getters

湖上湖 2018-08-31 18:14:15
我在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。
查看完整描述

2 回答

?
慕村225694

TA貢獻1880條經驗 獲得超4個贊

樓主,同遇到這種問題,解決了嗎?理解不過來有點

查看完整回答
反對 回復 2018-09-09
?
繁花不似錦

TA貢獻1851條經驗 獲得超4個贊

組件中建議使用mapGetters

computed:{
    ...mapGetters('carGetter')
},methods:{
    someFunction(){
        console.log(this.carGetter);
    }
}


查看完整回答
反對 回復 2018-09-09
  • 2 回答
  • 0 關注
  • 6065 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號