I'm beginner in vue
I'm trying to push a computed data with name , that name come from vuex which comes after creating the instance
How can i push new computed property to the instance in the created() hook ??
Here is the code
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)
        }
If I can create new computed value after creating that will solve the problem
You can do this in beforeCreate hook。
beforeCreate: function() {
  this.$options.computed = {
     demo2: function() {
       return this.demo
     }
  }
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With