鍍金池/ 問答/網(wǎng)絡(luò)安全  HTML/ vuex奇怪的問題,在組件中commit成功,但是數(shù)據(jù)沒有變化

vuex奇怪的問題,在組件中commit成功,但是數(shù)據(jù)沒有變化

在組件中commit

api.subscribe({ eventName: this.eventName, email: this.email }).then(res => {
          this.$store.commit('EMAIL', this.email)
        })

在store中接受到了數(shù)據(jù),控制臺輸出數(shù)據(jù)正常

//state
const state = {
  userId: '',
  email: ''
}
//mutations
[types.EMAIL](state, email) {
    console.log(email)
    state.email = email
  }

但是在vue devtools中email還是undefined

如果在store的action中commit,則一切正常

clipboard.png

回答
編輯回答
胭脂淚

搞了半天也不知道問題是什么鬼,把parcel換成webpack,問題解決
parcel構(gòu)建的只能dispatch,不能commit

2017年9月17日 03:57
編輯回答
雨蝶
mutations = {
    [types.EMAIL](state, email) {
        console.log(email)
        state.email = email
  }
}
2018年6月20日 02:27