-
-
Couldn't load subscription status.
- Fork 33.8k
Closed
Labels
Description
sometimes, we want to control two-way binding of v-model with bind the value (false or true) to a dynamic property on the Vue instance.
related issue: kazupon/vue-validator#149
use-cases
form field validation
case1: vue-validator
<validator name="validation1"> <input type="text" :sync="$validation1.username.valid" v-model="user.name" v-validate:username="{ minlength: { rule: 32 } }"> </validator>case2: user custom validation
<input type="text" :sync="valid" v-model="user.name" @input="onInputValidator">new Vue({ ... data: { user: { name: '' }, valid: false }, methods: { onInputValidator: function (e) { this.valid = e.target.value.length > 32 } } })spec
- if
syncattribute value istrue, two-way binding of v-model become enable. data is updated when occured user input events, - if
syncattribute value isfalse, two-way binding of v-model become disable. data is not updated when occured user input events,