i am appending a child component in Vue programmatically as seen below:
var ComponentClass = Vue.extend(FormulaGeneratorConstant) //create instance from FormulaGeneratorConstant component
this.constants.push('variable1');
var constant = new ComponentClass({
propsData: {
value: this.constants[this.constants.length - 1]
}
});
constant.$mount();
this.$refs.droppableContainer.$el.appendChild(constant.$el)
but right now i can only pass props in this code.
i would like to know how to implement v-model and handle custom events as well if that is possible.
Found the solution here.
i just passed a created
function inside the new Component
constructor:
var constant = new ComponentClass({
propsData: {
value: this.constants[this.constants.length - 1]
},
created(){
this.$on(['change'], e => { console.log(e); })
}
});