0

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.

1 Answer 1

1

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); })
    }
});

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.