問題是這樣的:我用render渲染了一個組件FormTask,F(xiàn)ormTask中有個子組件treeButton使用了Vuex中的全局數(shù)據(jù)。然后瀏覽器報原因就在于render渲染出來的組件的this已經(jīng)變了,不是原先Vue實例了,所以this找不到store屬性,更拿不到其中的全局數(shù)據(jù)了。deviceParentList () {
console.log('treeButton', this)
return this.$store.getters['getDeviceTree']
}問題都知道,但是就是不知道怎么解決,自己想的辦法就是在渲染FormTask時往prop傳入要使用的全局數(shù)據(jù),再FormTask傳給treeButton,但是這樣的操作好愚蠢,不知道各位大神有沒有更好的解決辦法,感激不盡!!!
添加回答
舉報
0/150
提交
取消