I try to v-bind the v-validate attr.
<input :v-validate="'validateStr'" name="email" v-model="model" @input="onInput">
computed: {
validateStr() {
return "required|email";
}
},
but it's not working.
Directives shouldn't use the colon for binding, the expression itself is bound automatically:
v-validate=" 'required' "
notice the extra single quotes (I added spaces for clarity), that is because we want it to be bound to a static string value.
You can bind it to an expression by passing it without the single quotes:
https://jsfiddle.net/eyf8b06q/9/
or bind it to a computed property or data property.
Most helpful comment
Directives shouldn't use the colon for binding, the expression itself is bound automatically:
notice the extra single quotes (I added spaces for clarity), that is because we want it to be bound to a static string value.
You can bind it to an expression by passing it without the single quotes:
https://jsfiddle.net/eyf8b06q/9/
or bind it to a computed property or data property.