Vue 2 → Vue 3 迁移债务报告

目标:vue-element-admin (github.com/PanJiaChen/vue-element-admin) · 生成于 2026/9/17 16:41:29 · 耗时 52ms
185遗留写法命中
466.5迁移债务指数 MDI
迁移量级 · 建议先立规范再动,避免边改边新增
72涉及文件
6依赖风险

按检测项汇总

级别检测项命中权重处置建议
high beforeDestroy / destroyed 生命周期 20 ×2 Vue 3 重命名为 beforeUnmount / unmounted,改名字即可,但要逐一确认清理逻辑
high .sync 修饰符 14 ×1 Vue 3 移除 .sync,改为 v-model:propName;子组件 emit 名从 update:xxx 保持一致
high slot-scope / slot="name" 旧插槽语法 98 ×3 Vue 3 只认 v-slot;<template slot-scope="x"> 要改成 <template #default="x">
high filters 过滤器 14 ×2 Vue 3 移除 filters 选项,改成 computed 或纯函数调用(模板里写 {{ fmt(x) }})
high Vue 全局 API(prototype / use / set ...) 19 ×3 Vue 3 改为 app.use / app.config.globalProperties;Vue.set|delete 直接删除(响应式系统已覆盖)
high $on / $off / $once / $listeners / $children 4 ×3 Vue 3 移除实例事件 API 与 $listeners/$children;EventBus 改用 mitt,父子通信改用 props/emit
medium functional: true 函数式组件 1 ×2 改成普通函数组件(props/emits 显式声明),Vue 3 中函数式组件是纯函数
medium Webpack / vue-cli 强耦合写法 6 ×1 Rspack 兼容大部分 loader 链,但 require.context 的写法、chainWebpack 配置要重写
medium mixins 引用 9 ×1.5 mixins 在 Vue 3 仍可用但同样导致数据来源不透明;建议迁移期换成组合式函数(composables)

最重的文件

文件命中
src\views\table\complex-table.vue17
src\views\example\list.vue10
src\views\table\drag-table.vue9
src\views\tab\components\TabPane.vue8
src\views\table\inline-edit-table.vue8
src\views\components-demo\mixin.vue6
src\views\dashboard\admin\components\TransactionTable.vue6
src\views\excel\export-excel.vue5
src\views\excel\merge-header.vue5
src\views\excel\select-excel.vue5
src\views\permission\role.vue5
src\views\zip\index.vue5
src\components\ErrorLog\index.vue4
src\views\components-demo\split-pane.vue4
src\main.js3

依赖风险

当前版本处置
echarts4.2.1echarts 4 及以下 —— 5.x API 有破坏性变更
element-ui2.13.2Vue 2 生态 UI 库 —— 需换 element-plus / vant 4
vue2.6.10Vue 2 —— 迁移主体,升到 3.x
vue-router3.0.2Vue Router 2/3 —— 升到 4/5,API 从 new Router() 改为 createRouter()
vuex3.1.0Vuex 3 —— 官方推荐迁移到 Pinia
@vue/cli-service4.4.4vue-cli —— 换 Rspack/Vite 构建

兼容性提醒(能装但要确认)

当前版本说明
element-ui2.13.2Vue 2 生态 UI 库 —— 需换 element-plus / vant 4 / view-ui-plus
vuedraggable2.20.0vuedraggable 2 —— Vue 3 需换 vuedraggable@next 或 vue-draggable-plus
vuex3.1.0Vuex 3 —— Vue 3 里能跑但官方推荐 Pinia;this.$store 在 setup 中不可用

逐条明细(含行号)

beforeDestroy / destroyed 生命周期 20 处

.sync 修饰符 14 处

slot-scope / slot="name" 旧插槽语法 98 处

filters 过滤器 14 处

Vue 全局 API(prototype / use / set ...) 19 处

$on / $off / $once / $listeners / $children 4 处

functional: true 函数式组件 1 处

Webpack / vue-cli 强耦合写法 6 处

mixins 引用 9 处