Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use V-model can add and modify a new state property #2145

Closed
ParkerFiend opened this issue Apr 18, 2023 · 2 comments
Closed

Use V-model can add and modify a new state property #2145

ParkerFiend opened this issue Apr 18, 2023 · 2 comments

Comments

@ParkerFiend
Copy link

Reproduction

https://stackblitz.com/edit/github-i1nwig-dydpjt

Steps to reproduce the bug

  1. change the input3
  2. setupStore got new property

Expected behavior

The setupStore property should not be add.

Actual behavior

New Property 'b' add to store by input3 v-model.

Additional information

In the doc

Note you cannot add a new state property if you don't define it in state(), it must contain the initial state.

If the component can add and modify the properties of the store at any time,
will the type definition for state lose its effectiveness?

And still got question in similar discussions: Doubts about using v-model

Copy link
Member

posva commented Apr 18, 2023

This is how JavaScript works: objects are passed by reference, not by value.
You are not adding state this way, it won't work in other scenarios like SSR. There are other examples in docs.

@posva posva closed this as not planned Won't fix, can't repro, duplicate, stale Apr 18, 2023
@ParkerFiend
Copy link
Author

Thanks for your reply.

You are not adding state this way, it won't work in other scenarios like SSR.

If there is no SSR scenario in the project, any solution to avoid the above situation?
Compare to Vuex, v-model got the same result or not?
Looking forward to resolving doubts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants