elementui包
Element UI 简介
Element UI 是一套基于 Vue.js 的桌面端组件库,由饿了么前端团队开发并开源。它提供了丰富的 UI 组件(如表格、表单、弹窗等),适合快速开发企业级中后台产品。
安装 Element UI
通过 npm 或 yarn 安装:
npm install element-ui --save
# 或
yarn add element-ui
在项目中全局引入:
import Vue from 'vue';
import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';
Vue.use(ElementUI);
按需引入(推荐):
npm install babel-plugin-component -D
修改 .babelrc 或 babel.config.js:
{
"plugins": [
["component", { "libraryName": "element-ui", "styleLibraryName": "theme-chalk" }]
]
}
按需导入组件示例:
import { Button, Select } from 'element-ui';
Vue.component(Button.name, Button);
Vue.component(Select.name, Select);
核心特性
-
组件丰富
包含表单、表格、弹窗、导航等 50+ 组件,覆盖常见业务场景。 -
主题定制
通过 主题生成工具 在线修改主题色,或使用 SCSS 变量覆盖。
-
国际化支持
提供多语言切换能力,默认支持中文、英文等。 -
响应式设计
适配不同屏幕尺寸,部分组件支持移动端交互。
基础使用示例
按钮组件:
<el-button type="primary">主要按钮</el-button>
<el-button plain>朴素按钮</el-button>
表单组件:

<el-form :model="formData" label-width="80px">
<el-form-item label="用户名">
<el-input v-model="formData.username"></el-input>
</el-form-item>
<el-form-item>
<el-button type="primary" @click="submit">提交</el-button>
</el-form-item>
</el-form>
表格组件:
<el-table :data="tableData">
<el-table-column prop="date" label="日期"></el-table-column>
<el-table-column prop="name" label="姓名"></el-table-column>
</el-table>
注意事项
-
版本兼容性
Element UI 需搭配 Vue 2.x 使用。Vue 3.x 项目需使用 Element Plus。 -
浏览器支持
兼容现代浏览器及 IE 10+,部分功能需 Polyfill 支持。 -
性能优化
按需引入可减少打包体积,避免全局引入所有组件。 -
维护状态
Element UI 已进入维护模式,新项目建议优先考虑 Element Plus。
如需进一步了解,可查阅 官方文档。





