添加新的計算值,我在VUEVUE計算:從創建生命週期掛鉤
我試圖推動與名稱的計算數據初學者,這個名字來自vuex其中談到創建實例後
如何將新的計算屬性推到created()鉤子中的實例?
下面是代碼
computed: {
// 3 - i want to extract the object properties here computed
// that is easy bu using spread operator ...
// Problem : vue intialize computed before the created() hook
// so the spreed work befor passing the filling the object
...this.mapGettersObj
},
created(){
// 1- i can access only this line after creating the object
this.stocks = this.$store.state
let arr=[]
for (let stock in this.stocks){
arr.push(stock+'Getter')
}
// 2 - mapGetters returns an object
this.mapGettersObj=mapGetters(arr)
}
如果我能創建將解決這個問題
請包括你的工作代碼,並表示你已經試過了沒有奏效。 – PatrickSteele
我已經插入的代碼 –