鍍金池/ 問答/HTML/ methods中能$store.state,在mounted中調(diào)用methods

methods中能$store.state,在mounted中調(diào)用methods中方法時(shí)提示undefined。

同一個(gè)組件中,mounted中調(diào)用了methods中的一個(gè)方法。
但是methods中使用不報(bào)錯(cuò)
mounted一調(diào)用就提示$store is undefine
請問一下這是怎么回事呢?

回答
編輯回答
嫑吢丕

不知道是不是生命周期的問題,
把mounted中的方法放到了updated中就能夠調(diào)用了

2018年3月27日 11:55
編輯回答
笨小蛋

應(yīng)該是this.$store.commit('functionName')觸發(fā)vuex中的方法
this.functionName 調(diào)用methods中的方法

2017年10月31日 01:13