【发布时间】:2017-05-04 11:48:54
【问题描述】:
我是 vue 初学者
我正在尝试使用 name 推送计算数据,该名称来自创建实例后的 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)
}
如果我可以在创建后创建新的计算值,那将解决问题
【问题讨论】:
-
请包含您正在处理的代码,并说明您已经尝试过哪些没有用。
-
我已插入代码
标签: vue.js vue-component