第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

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

vuex 狀態(tài)樹的使用

vuex 狀態(tài)樹的使用

交互式愛情 2018-09-02 11:51:09
 export const state = () => ({    wishNum: 0   });  export const mutations = {   SET_WISH: (state) => {     state.wishNum = 0;  }, }  let Num = res.total; setStore("wishNum", Num);##我這樣寫對不對。我獲取不到$store.state.user.wishNum的值本地的值在變化然而他還是0。
查看完整描述

2 回答

?
婷婷同學(xué)_

TA貢獻(xiàn)1844條經(jīng)驗 獲得超8個贊

不是$store.state.wishNum嗎?

查看完整回答
反對 回復(fù) 2018-09-02
?
慕妹3242003

TA貢獻(xiàn)1824條經(jīng)驗 獲得超6個贊

state 和 mutations 放在一個文件中嗎?
你可以分開寫 state.js

export default {    wisNum: 0}

mutations.js

export default {
    SET_WISH: (state, payload) => {        state.wishNum = payload
    }
}

index.js中

import state from './state.js'
import mutations from './mutations.js'
export default new Vuex.Store({    state, mutations
})

Vue組件中

this.$store.commit('SET_WISH', 12)

main.js中

import store from './store/index.js'new Vue({
  el: '#app',
  router,
  components: { App },  template: '<App/>',
  store
})


查看完整回答
反對 回復(fù) 2018-09-02
  • 2 回答
  • 0 關(guān)注
  • 851 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號