link-center
项目的技术栈比较老旧,未来可以预测到许多业务需要在最新的 的基础上进行开发,靠原生 手写实现封装花费时间较多且稳定性不是很好,比如实现一个日期组件Element
Vue
Vue
vue-easytable
vue-treeselect
Vue 2.x
Vue 2.x
1.4.13
Element 2.x
移除 中的 版本package.json
element-ui
// package.json element-ui: '2.15.7'
安装最新版本
$ npm install element-ui @2.15.7 -S
src/index.js
theme-chalk
import 'element-ui/lib/theme-default/index.css
import 'element-ui/lib/theme-chalk/index.css
theme-defaulttheme-chalk
有的组件样式需要进行定制覆盖,于是就在组件里面用 进行了同类名的样式替换,这样在开发环境下效果是符合预期的,但是打包编译后,优先级就变了。需要在 修改引入文件路径顺序的问题css scoped
src/index.js
修改前:
import Vue from 'vue' import App from './App.vue' import ElementUI from 'element-ui' import 'element-ui/lib/theme-chalk/index.css' Vue.use(ElementUI)
修改后:
import Vue from 'vue' import ElementUI from 'element-ui' import 'element-ui/lib/theme-chalk/index.css' import App from './App.vue' Vue.use(ElementUI)
Vue packages version mismatch
element ui
Vue
vue-template-compiler
$ npm install vue-template-compile @2.6.14 -S
_v
Element 2.x
Vue 2.5.x
$ npm uninstall vue $ npm install vue@2.6.12
TypeError: VueLoaderPlugin is not a constructor
// webpack.config.js const { VueLoaderPlugin } = require('vue-loader') module.exports = { module: { rules: [ { test: /\.vue$/, loader: 'vue-loader' } ] }, plugins: [ // 请确保引入这个插件! new VueLoaderPlugin() ] }
vue-loader
也需要升级,以便支持Element 2.x
icon
Button
icon
Checkbox
的 事件中,参数由 变为了change
event
value
input
icon
suffix-icon
suffix
on-icon-click
click
slot
change
事件现在仅在输入框失去焦点或用户按下回车时触发,与原生 元素一致。如果需要实时响应用户的输入,可以使用 事件input
input
block
inline-block
Input
的 属性被传递到了最底层的 元素,需要关注有 的id
input
id
el-input
block
inline-block
Select
,值为对象类型时,需要提供一个 作为唯一性标识value-key
Select
,过滤情况下, 为选中选项的placeholder
label
on-*
Switch
on-*
on-*
active-
off-
inactive-*
on-icon-class、off-icon-class、on-text、off-text、on-color、off-color、on-value、off-value
active-text
和 属性不再有默认值inactive-text
change
’’
null
timepicker
timepicker
Upload
重构升级, 属性更名为 , 属性更名为 , 属性被移除default-file-list
file-list
show-upload-list
show-file-list
thumbnail-mode
Form validateField()
方法回调的参数更新Form
移除输入框的成功状态inline-template
sort-method
现在和 保持一致的逻辑,要求返回一个数字Array.sort
append slot
tbody
expand
事件更名为 ,以保证 的命名一致性expand-change
API
row-class-name
和 的函数参数改为对象,以保证 的一致性row-style
API
type
属性现在支持 四个值success、info、warning 和 danger
change
Pagination
current-change
Loading
z-index
Loading
z-index
inline-block
block
Tab-Pane
label-content
Tabs
现在内部不再维护 实例,需要在外部通过相关事件去处理tab
menu-align
属性变更为 ,增加更多方位属性placement
show-timeout
和 属性现在仅在 为 时生效hide-timeout
trigger
hover
Dialog
的遮罩层现在默认插入至 元素上body
size
Dialog
width
fullscreen
v-model
Dialog
Tooltip
HTML
tooltip
el-tooltip
标签中,子元素如果有 ,则需要为 也加上v-if
el-tooltipv-if
虽然项目能跑起来了,但是控制台还会有很多警告,一部分是来自 本身的警告,还有一些是 的非兼容属性或者即将废弃的属性所带来的警告,需要我们对这些警告进行修改。常见的有:Vue
Element
v-for
循环渲染组件时,必须为组件绑定 值key
v-for
绑定的 值中,存在同样的 值key
key
Element
中的废弃属性带来的警告,比如: 中的 改为input
iconsuffix-icon
Copyright © 2023 leiyu.cn. All Rights Reserved. 磊宇云计算 版权所有 许可证编号:B1-20233142/B2-20230630 山东磊宇云计算有限公司 鲁ICP备2020045424号
磊宇云计算致力于以最 “绿色节能” 的方式,让每一位上云的客户成为全球绿色节能和降低碳排放的贡献者