v-model should generate ref assignment code for setup-reactive-const bindings
Vue version
3.2.45
Link to minimal reproduction
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
You should use ref
for a primitive value
https://sfc.vuejs.org/#eNp9kMtuwjAQRX9lNBtaidiij00aKvof3tBkKGnxQ/YkLKL8e8dJKwWQ8M73js8ZecCPEFTfEZZoXMVkw2nP9G4cyKlaFzqGvrC+odPW4PkoZU/RIGiZqfTigVxTHdvAkIi7MCEMtzb4yDBEOoxwiN7CSmyrmV97lxj+obAFmXrYbB7fMnqGTWDANc6gwu6D+k7eyb7DZPgrksESpiRnosh3g0fmkEqtOxd+vlTtrd5Jp2PnZDMqGm93z+pJvbzqpk28zBUlW3xGf04UxWhwvYBrCWXjIpJrKOb/uCO7mr0QXnU30uwcjRtx/AVnQ5KK
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.
the primitive value here is just a example
see this =>
to reassign an array with v-model, like
this example @sxzz @LinusBorg