How to use Vue js data variables value in as parameter?
<input type="text" :value="totalWeek1" name="totalWeek1" v-validate="'between:min,max'"/>
data:{
min:5,
max:10
}
I have found a trick
<input type="text" :value="totalWeek1" name="totalWeek1" v-validate="validation"/>
data:{
validation:'',
min:5,
max:10,
}
` mounted: function()
{
this.validation='between:'+this.min+','+this.max;
},`
This is not a beautiful code but it works. Someone for a best solution?
If you are using ES6, you can use template string for this:
<input type="text" :value="totalWeek1" name="totalWeek1" v-validate="`between:${min},${max}`"/>
This is not working. I get:
The totalWeek1 field must be between ${min} and ${max}.
I I'm using ES6 (using Laravel 5.4)
The browser must be capable of ES6, unless you use vue-loader which should convert it with babel for you.
this worked for me
<input v-validate="'required|min_value:1|max_value:' + months">
where
data ()
return {
months: 12
}
Most helpful comment
this worked for me
<input v-validate="'required|min_value:1|max_value:' + months">where