项目从vue2迁移到vue3,v-model不能再使用了,需要如何调整?
下面只提示变化最小的迁移,不赘述vue2和vue3中的常规写法。
vue2迁移到vue3,往往不想去调整之前的代码,以下就使用改动较小的方案进行调整。
In terms of what has changed, at a high level:
- BREAKING: When used on custom components,
v-model
prop and event default names are changed:- prop:
value
->modelValue
; - event:
input
->update:modelValue
;
- prop:
- BREAKING:
v-bind
's.sync
modifier and componentmodel
option are removed and replaced with an argument onv-model
; - NEW: Multiple
v-model
bindings on the same component are possible now; - NEW: Added the ability to create custom
v-model
modifiers.
For more information, read on!
以上文档来自