牟长青 做网站推广的四个基本要点,html网站制作模板,seo网络推广到底是做什么的,申请网站怎样申请项目从vue2迁移到vue3#xff0c;v-model不能再使用了#xff0c;需要如何调整#xff1f;
下面只提示变化最小的迁移#xff0c;不赘述vue2和vue3中的常规写法。
vue2迁移到vue3#xff0c;往往不想去调整之前的代码#xff0c;以下就使用改动较小的方案进行调整。
I…项目从vue2迁移到vue3v-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;BREAKING: v-binds .sync modifier and component model option are removed and replaced with an argument on v-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!
以上文档来自v-model | Vue 3 Migration GuideGuide on migrating from Vue 2 to Vue 3https://v3-migration.vuejs.org/breaking-changes/v-model.html
翻译结果
就发生的变化而言在高水平上 BREAKING在自定义组件上使用时v模型道具和事件默认名称会发生更改 prop:value-modelValue event:input-update:modelValue BREAKINGv-bind的.sync修饰符和组件模型选项被删除并替换为v-model上的一个参数 新功能现在可以在同一组件上进行多个v模型绑定 新增增加了创建自定义v型模型修改器的功能。 有关更多信息请继续阅读
下面看代码调整
简单写一个例子vue2
templateview clickonAdd{{ value }}/view
/template
script
export default {props: {value: Number},methods: {onAdd(){this.$emit(input, this.value 1)}}
}
/script
上面改成(vue3)
templateview clickonAdd{{ modelValue }}/view
/template
script
export default {props: {modelValue: Number},methods: {onAdd(){this.$emit(update:modelValue, this.value 1)}}
}
/script 下面将支出vue2迁至vue3需要修改的地方见下图