Description
@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?