core icon indicating copy to clipboard operation
core copied to clipboard

v-model update being bubbled up on root components

Open Kurira opened this issue 6 years ago • 1 comments

Version

3.0.0-rc.4

Reproduction link

https://codesandbox.io/s/hungry-mendeleev-dfiy9

Steps to reproduce

  1. Open https://codesandbox.io/s/hungry-mendeleev-dfiy9
  2. Press count button

What is expected?

It should correctly increase count value to 3 and so on. Works on vue2.

What is actually happening?

Now it sets the whole wrapper object to that number, instead of the property.


Wrapping hello component in a div works as a workaround.

Kurira avatar Jul 26 '20 15:07 Kurira

In your example your Hello component is using v-model but it should just pass a prop since it's not modifying its modelValue prop. Otherwise you have to provide the inheritAttrs: false option to it so it doesn't inherit the binding and event listener from its parent and put it on the Test component, which conflict with the added v-model. That's also why a wrapper fixes the problem.

You can find more information at existing RFCs like https://github.com/vuejs/rfcs/pull/31

posva avatar Jul 27 '20 08:07 posva