Skip to content

Moving v-bind.sync to the v-model API #8

Closed
@chrisvfritz

Description

@chrisvfritz

@yyx990803 I've seen v-bind.sync cause quite a bit of confusion in Vue 2, as users expect it to be able to use expressions like with v-bind (despite whatever we put in the docs). The explanation I've had the best success with is:

Thinking about :title.sync="title" like a normal binding with extra behavior is really the wrong way to think about it, because two-way bindings are fundamentally different. The .sync modifier works essentially like v-model, which is Vue's other syntax sugar for creating a two-way binding. The main difference is that it expands to a slightly different pattern that allows you to have multiple two-way bindings on a single component, rather than being limited to just one.

Which brings me to the question: if it helps to tell users not to think of v-bind.sync like v-bind, but rather to think about it like v-model, should it be part of the v-model API instead? For example, instead of:

<MyComponent v-bind:title.sync="title" />

Perhaps a more intuitive syntax would be:

<MyComponent v-model:title="title" />

As a bonus, a change like this would be very easy to flag with the migration helper and fix with find-and-replace.

Thoughts?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions