Is v-model counter-intuitive? #11376
Gregoor
started this conversation in
General Discussions
Replies: 1 comment 5 replies
-
|
Beta Was this translation helpful? Give feedback.
5 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi!
I've just boiled a few hour bug chase down to this.
Now I'm wondering if other people have run into this confusion, namely that
v-model
setting a two-way binding means that whatever you pass in, will be mutated in-place.Maybe it's my React background, but this seems mighty implicit for something that can cause such subtle bugs. In my case I had a deep object, where mutation happened in some leaf object, which would then also change the preset which it was originally a reference to.
My solution was to do a deep copy instead of reusing objects.
I would see value in more explicit documentation about it, but overall I also have to say that I find such an API obtuse
Beta Was this translation helpful? Give feedback.
All reactions