Answer the question
In order to leave comments, you need to log in
How to pass v-model through component wrapper?
Hello. In my project, I use Vuetify, for convenience, I wrap all form elements with my component. I am interested in such a moment as the easiest way to connect the v-model of the parent and child components. Right now I'm using this design
export default {
template: '<v-text-field v-model="model"></v-text-field>',
props: ['value'],
data(){
return {
model: '',
}
},
created(){
this.model = this.value;
},
mounted() {
this.model = this.value;
},
watch: {
value(){
this.model = this.value;
},
model(){
this.$emit('input', this.model)
},
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question