Vue: why should i emit a event manually when using sync?

Created on 28 Apr 2017  Â·  2Comments  Â·  Source: vuejs/vue

What problem does this feature solve?

i think it's better to use ‘twoWay’ keyword to instead it like vue1.x did,and i think there is a simple way for 'v-model',users need not to emit a input event manually,but just specify the model.prop.

What does the proposed API look like?

let twoWay back and users dont need emit update event manually because it's complicated to emit event everywhere,and we need not emit inpt event when using v-model,we just need specify model.prop,the vue framework can do the rest better than user.

Most helpful comment

No, implicitly affecting parent by mutating props is exactly what we want to avoid.

All 2 comments

No, implicitly affecting parent by mutating props is exactly what we want to avoid.

@yyx990803 Maybe we can specify a binding data prop when using props, like this:
javascript value: { type: String, default: 'foo', bind: 'innnerValue' }
then it can generate a field called 'innnerValue' on this.$data and its defalut value is 'foo',when we modify this.innnerValue,the framework can emit a 'update:value' event automatically.And,if you modify the prop 'value' by parent,it will update to innnerValue.You can use 'sync' to accept the change,you also can use 'v-model' after you specify model.prop.

5548

Was this page helpful?
0 / 5 - 0 ratings

Related issues

loki0609 picture loki0609  Â·  3Comments

julianxhokaxhiu picture julianxhokaxhiu  Â·  3Comments

bfis picture bfis  Â·  3Comments

seemsindie picture seemsindie  Â·  3Comments

gkiely picture gkiely  Â·  3Comments