Element Plus Breaking Changes (English version) #5658
Replies: 4 comments 7 replies
-
|
Thank you for making this list 😃 |
Beta Was this translation helpful? Give feedback.
-
|
i am also interested in dark/light theme switch |
Beta Was this translation helpful? Give feedback.
-
|
if i still use element-plus-v1-beta,where can i find the document?now the document on the official webside is about v2,and i can switch the version~ |
Beta Was this translation helpful? Give feedback.
-
|
How can I access the ref in Element Plus (version 2.9.4) and Vue 3.5.13? I tried using this.$refs.popover.hide(), but it threw an error. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
This documentation will list breaking changes with Element UI 2.x.
Dev Environment
Vue CLI
If you use Vue CLI as your build tool, please upgrade to latest version, both v4 and v5 are acceptable.
Webpack 4
If you use Webpack 4 as your build tool, please consider the code below.
Webpack 5
If you use Webpack 5 as your build tool, please consider the code below.
Compatibility
The table below shows the minimum browser requirements for Element Plus.
If you want to use Element Plus normally on lower version browsers, please manually use Babel, ESBuild or other transform tools and import corresponding polyfills.
It is worth noting that Element Plus uses
ResizeObserver, you need to import resize-observer-polyfill. For details, see ResizeObserver Compatibility. Please refer to the documentation for more details.Font Icon Removed
Class name based Font Icon has been removed, which means you need to migrate all
el-icon-related code to SVG Font, and please refer to the comparison table below. For more details about SVG icons, you can refer to documentation. You can also use the unplugin-icons plugin for automatic import.Element UI
Element Plus
Release Package
The source code
/packagesof Element Plus has been removed in the npm release package. If you need, please copy the source code yourself.Install
Import
The import path of Element Plus is different from that of Element UI. Please consider the code below. For more methods, please refer to Installation Documentation
Global Configuration
Global configuration
Vue.prototype.$ELEMENThas been removed, please consider the code below.Or use config-provider component, please consider the code below.
Design
The component size system is switched from default / medium / small / mini to large / default / small.
defaultwill be the default size, uselargeif you need to increase it, or usesmallto reduce the size. In terms of Padding, it is optimized to a more general 4px system, using 4/8 px as the atomic unit to control the padding consistency of the entire system. That is, the padding of large components is also large, and the padding of small components is also small.The main components involved are Button, Radio, Checkbox, Input, Select, DatePicker, Form, Table, Tag, and other components with size properties.
It mainly involves attributes such as padding and margin attribute modification, font-size and other font and icon size modification, etc.
Custom Theme
Sass
In the
.scssfile, import all styles:Due to the scope of
@use, when using a variable, you need to export it, or forward the variable through@forward. For example:'\*'means no namespace, it can also be named.Forward app variables via the
@forwardsyntax:Variable
-background-color->-bg-color-font-color->-text-colorThe variable name naming will be similar to the variable naming in tailwindcss.
The variables of each component are organized using
@use 'sass:map';, and the variables of the corresponding component are moved to the corresponding component name.See
element-plus/theme-chalk/src/common/var.scssfor exposed variables.For example, the default variable for the
switchcomponent is:User-defined variables: (will automatically override and merge default variables)
For more details, please refer to Custom theme.
Internationalization
Element Plus uses English as the default language. To change the default language, please refer to the Global Configuration section and set the
localeproperty.For more details, please refer to documentation.
Component
Since Vue 3 changed the property name of
v-modelfromvaluetomodel-value, if you use thevalueproperty, please change it tomodel-value(v-modelno special The description does not need to be modified), and will not be repeated later.Layout
Row
typeDialog
visiblemodel-value/v-modelMenu
ElSubmenu/el-submenuElSubMenu/el-sub-menuPopconfirm
on-confirmconfirm2.14.0on-cancelcancel2.14.0Timeline
reverseDate Picker / Time Picker / DateTime Picker
picker-optionspicker-options.formatformatpicker-options.selectableRangedisabled-hours/disabled-minutes/disabled-secondsfirst-day-of-weekdefault-timeDateobjects are supportedTooltip
popper-optionsthis property is completely different from v1.
See popperjs documentation.
offset0to12open-delayshow-afterclose-delayhide-afterhide-afterauto-closeCalendar
valuemodel-value/v-modelrangefirst-day-of-weekPopover
open-delayshow-afterclose-delayhide-afterhide-afterauto-closeScrollbar
wrapwrap$Form
float layout has been changed to flex layout.
validatePromiseofreject, no longerfalseFor more details about features and breaking changes, please see this (in Chinese)
Templates
The following is a quick start template, I believe it will help you.
Beta Was this translation helpful? Give feedback.
All reactions