[Vuejs]-It's there any way to get v-model's variable name in the parent component from a child component

0👍

You can emit an event with any name you want, so in the child you can write:

<input type="radio" @input="$emit('prop', prop)" v-model="prop" :value="value">

Then in the parent you can do:

<radio-component v-model="radio1" @prop="doSomething" value="1" name="nameValue"></radio-component>
.
.
.
data(){
   return {
     nameValue: null
    }
methods: {
doSomthing(prop){
   this.nameValue = prop
}
}

Leave a comment