i have a custom component with 2 inputs let say date_on
and date_off
i want to bind that component to current object .
note i don't want to use any computed value or function to keep using it on different component without adding extra methods.
using computed variable it works fine but using inLine
object it gives me this error :
'v-model' directives require the attribute value which is valid as LHS
data() {
return {
dateOn1: '',
dateOff1: '',
dateOn2: '',
daeOff2: ''
}
},
computed:{
dates:{
get(){
return {dt_on:this.dt_on1,dt_off:this.dt_off1};
}
set(value){
this.dt_on1 = value.dt_on;
this.dt_off1= value.dt_off;
}
}
}
<template>
<my-dates v-model="{dateOn:dateOn1,dateOff:dateOff1 }"></my-dates>
<my-dates v-model="{dateOn:dateOn2,dateOff:dateOff2 }"></my-dates>
<my-dates v-model="dates"></my-dates> <!-- work fine -->
</template>