Is there any practical difference between .sync
and v-model
on a component?
Both seem to do the same thing:
<comp :value.sync="bar"></comp>
expands to:
<comp :value="bar" @update:value="val => bar = val"></comp>
<comp v-model="bar"></comp>
expands to:
<comp :value="bar" @input="val => bar = val"></comp>
I’ve updated the attributes in the links above to make the comparison clearer (hopefully I’ve not mistyped them).
The differences I can see are:
- the default prop name
- .sync allows you to use multiple props
- the event name you emit from your component
I ask as I’m about to go through our component library and bring some consistency to it / remove some bugs.
We’re currently using .sync
but I’m wondering if v-model
would be more obvious.
Cheers,
Dave