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

v-model should generate ref assignment code for setup-reactive-const bindings #7429

Closed
baohangxing opened this issue Dec 29, 2022 · 5 comments

Comments

@baohangxing
Copy link

Vue version

3.2.45

Link to minimal reproduction

https://sfc.vuejs.org/#eNp9kM1OwzAQhF9ltZeC1NgqP5eQovIevoRkoYH6R/YmPUR5d9YJlUKR6tvOrOcb7YhvIaihJyzRuIrJhlPN9GocyKs6F3qGobC+pdPe4Pko5kDRIGjZqfTqg4ypiV1gSMR9mCMMdzb4yDBGqhvuBprgI3oLG0FuFkjjXWK4JMMeLqt3u939S4YssTMCcItLZGHroL6Sd9J8nFm/RjJYwqxkTTh5NnhkDqnUunfh+1M13uqDeDr2TjpS0Xp7eFQP6ulZt13ita4o2eI9+nOiKESD21W4FlFqF5FcSzFf5gbsavcP8Mr7B83MybgJpx8a4pa2

Steps to reproduce

type something

What is expected?

no error

What is actually happening?

Assignment to constant variable.

System Info

No response

Any additional comments?

in version 3.2.44, v-model generate ref assignment code for setup-reactive-const bindings, this commit changed it

I think generating ref assignment code for setup-reactive-const bindings is right, just like const a = ref(1) ("a": "setup-ref"), and it maybe an object in reactive like const whatever = reactive([]);

so v-model should generate ref assignment code for setup-reactive-const bindings

@LinusBorg
Copy link
Member

this commit is a fix for #6241, and it's the correct, intended behavior. as @sxzz correctly says: to reassign a "variable" with v-model, use a ref.

@baohangxing
Copy link
Author

the primitive value here is just a example

see this =>
to reassign an array with v-model, like
this example @sxzz @LinusBorg

@baohangxing
Copy link
Author

baohangxing commented Dec 29, 2022

thanks

@LinusBorg
Copy link
Member

Again: for that, we need to use a ref()

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
3 participants