Subscribe on changes!

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

avatar
Dec 29th 2022

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

avatar
Dec 29th 2022

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.

avatar
Dec 29th 2022

the primitive value here is just a example

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

avatar
Dec 29th 2022

thanks

avatar
Dec 29th 2022

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