Vue2.js迁移到Vue3.js的API变化

举报
彭世瑜 发表于 2022/08/27 22:58:23 2022/08/27
【摘要】 Vue2.js迁移到Vue3.js的API变化,-表示移除 Vue2.jsVue3.jsnew Vue()createApp()Vue.extenddefineComponent or extendsV...

Vue2.js迁移到Vue3.js的API变化,-表示移除

Vue2.js Vue3.js
new Vue() createApp()
Vue.extend defineComponent or extends
Vue.prototype app.config.globalProperties
Vue.set -
Vue.delete -
Vue.observable reactive
config.keyCodes -
vm.$set -
vm.$delete -
vm.$on -
vm.$off -
vm.$once -
vm.$children -
vm.$listeners -
hook:x -
vm.$scopedSlots -
vm.$slots now exposes functions
$attrs now includes class and style
data must be a function in all cases
data from mixin or extension is now shallow merged
beforeDestroy beforeUnmount
destroyed unmounted
v-on no longer supports keyCode modifiers
- watching an array no longer triggers on mutation unless deep
- Custom directive hook names changed
- No longer removes attribute if binding value is boolean false
- No longer special case enumerated attributes
<transition-group> no longer renders a root element by default
- Async component API changed (now requires defineAsyncComponent)
- Functional component API changed (now must be plain functions)
- Component v-model reworked
- Render function API changed
- Filters removed (this option affects only runtime filter APIs)
- is usage is now restricted to <component> only
v-bind.sync replaced by v-model with arguments
v-bind.prop modifier removed
v-bind=“object” is now order sensitive
v-on.native modifier removed
- ref in v-for (compiler support)
<template> with no special directives now renders as native element
- filters (compiler support)

参考
https://v3-migration.vuejs.org/migration-build.html#fully-compatible

文章来源: pengshiyu.blog.csdn.net,作者:彭世瑜,版权归原作者所有,如需转载,请联系作者。

原文链接:pengshiyu.blog.csdn.net/article/details/126547647

【版权声明】本文为华为云社区用户转载文章,如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱: cloudbbs@huaweicloud.com
  • 点赞
  • 收藏
  • 关注作者

评论(0

0/1000
抱歉,系统识别当前为高风险访问,暂不支持该操作

全部回复

上滑加载中

设置昵称

在此一键设置昵称,即可参与社区互动!

*长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。

*长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。