Skip to content

feature request: control the two-way binding for v-model #2845

@kazupon

Description

@kazupon

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 sync attribute value is true, two-way binding of v-model become enable. data is updated when occured user input events,
  • if sync attribute value is false, two-way binding of v-model become disable. data is not updated when occured user input events,

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions