Elment UI的使用说明
一、 Elment UI
1、 简介
Element UI是饿了么团队提供的一套基于Vue2.0的组件库,可以快速搭建网站,提高开发效率,就如同bootstrap。
2、组件分类
ElementUI 适用于PC端
MintUI 适用于手机移动端
3、官网
http://element.eleme.io/
二、快速上手
1、 安装elment ui
cnpm install element-ui -S
2、 在main.js中引入并使用组件(全局引入)
1、import ElementUI from 'element-ui' //只是引入了ElementUI的js文件
2、import 'element-ui/lib/theme-default/index.css' //该样式文件需要单独引入,引入的是ElementUI的css样式文件
3、Vue.use(ElementUI); //使用ElementUI组件,这种方式引入了ElementUI中所有的组件
4、示例:
![](/assets/blank.gif)
![](/assets/blank.gif)
import Vue from 'vue' import ElementUI from 'element-ui' import 'element-ui/lib/theme-default/index.css' //该样式文件需要单独引入 import App from './App.vue'Vue.use(ElementUI);new Vue({el: '#app',render: h => h(App) })
View Code
3、 在webpack.config.js中添加loader
1、 CSS样式和字体图标都需要由相应的loader来加载,所以需要style-loader、css-loader
2、默认并没有style-loader模块,所以需要单独安装
cnpm install style-loader --save-dev
3、示例
![](/assets/blank.gif)
![](/assets/blank.gif)
var path = require('path') var webpack = require('webpack')module.exports = {entry: './src/main.js',output: {path: path.resolve(__dirname, './dist'),publicPath: '/dist/',filename: 'build.js'},module: {rules: [{test: /\.vue$/,loader: 'vue-loader',options: {loaders: {}// other vue-loader options go here}},{test: /\.js$/,loader: 'babel-loader',exclude: /node_modules/},{test: /\.(png|jpg|gif|svg)$/,loader: 'file-loader',options: {name: '[name].[ext]?[hash]'}},{test:/\.css$/,loader:'style-loader!css-loader'//加载elment ui的style和css},{test: /\.(eot|svg|ttf|woff|woff2)(\?\S*)?$/,loader: 'file-loader'},{test:/\.less$/,loader:'less-loader'}]},resolve: {alias: {'vue$': 'vue/dist/vue.esm.js'}},devServer: {historyApiFallback: true,noInfo: true},performance: {hints: false},devtool: '#eval-source-map' }if (process.env.NODE_ENV === 'production') {module.exports.devtool = '#source-map'// http://vue-loader.vuejs.org/en/workflow/production.htmlmodule.exports.plugins = (module.exports.plugins || []).concat([new webpack.DefinePlugin({'process.env': {NODE_ENV: '"production"'}}),new webpack.optimize.UglifyJsPlugin({sourceMap: true,compress: {warnings: false}}),new webpack.LoaderOptionsPlugin({minimize: true})]) }
View Code
4、 使用组件
![](/assets/blank.gif)
![](/assets/blank.gif)
<template><div id="app">{{msg}}<br><!-- 按钮 --><el-button type="primary">我的按钮</el-button><el-button type="danger">我的按钮</el-button><el-button type="info">我的按钮</el-button><el-button type="warning">我的按钮</el-button><el-button type="success">我的按钮</el-button><br><br><el-button type="success" icon="edit">编辑</el-button><el-button type="success" icon="search">搜索</el-button><el-button type="primary">上传<i class="el-icon-upload el-icon--right"></i></el-button><hr><br><!-- 图标 --><i class="el-icon-close"></i><i class="el-icon-delete"></i><i class="el-icon-loading"></i><hr><!-- 布局 --><el-row><el-col :span="6" class="grid">welcome</el-col><el-col :span="6" class="grid">to</el-col><el-col :span="6" class="grid">itany</el-col><el-col :span="6" class="grid">网博</el-col></el-row><el-row><el-col :span="12" class="grid">welcome</el-col><el-col :span="12" class="grid">to</el-col></el-row><hr><!-- 日期选择器 --><DatePicker></DatePicker><!-- 文件上传 --><Upload></Upload></div> </template><script> import DatePicker from './components/DatePicker.vue'//引入自己定义的组件 import Upload from './components/Upload.vue'export default {name: 'app',data () {return {msg: '欢迎来到南京网博'}},components:{//注册自己引入的组件DatePicker,Upload} } </script><style lang="less"> /* 必须要指定lang="less" */.grid{border:1px solid #ccc;font-size:20px;color:@color;.h(50px);}@color:red;.h(@height){height:@height;} </style>
APP.VUE
![](/assets/blank.gif)
![](/assets/blank.gif)
<template><el-date-pickerv-model="value"type="date"placeholder="选择日期"size="small":picker-options="options"></el-date-picker> </template><script>export default {data(){return {value:'',options:{disabledDate(time) {return time.getTime() < Date.now() - 8.64e7;//计算时间在今天之前},firstDayOfWeek:1}}}} </script>
DatePicker.vue
![](/assets/blank.gif)
![](/assets/blank.gif)
<template><el-uploadclass="upload-demo"action="https://jsonplaceholder.typicode.com/posts/":on-preview="handlePreview":on-remove="handleRemove":file-list="fileList"><el-button size="small" type="primary">点击上传</el-button><div slot="tip" class="el-upload__tip">只能上传jpg/png文件,且不超过500kb</div></el-upload> </template><script>export default {data(){return {fileList: [{name: 'food.jpeg', url: 'https://fuss10.elemecdn.com/3/63/4e7f3a15429bfda99bce42a18cdd1jpeg.jpeg?imageMogr2/thumbnail/360x360/format/webp/quality/100'}, {name: 'food2.jpeg', url: 'https://fuss10.elemecdn.com/3/63/4e7f3a15429bfda99bce42a18cdd1jpeg.jpeg?imageMogr2/thumbnail/360x360/format/webp/quality/100'}]}},methods: {handleRemove(file, fileList) {console.log(file, fileList);},handlePreview(file) {console.log(file);}}}</script>
Upload.vue
5、 使用less(动态css,在style中必须要指定lang="less")
1、安装loader,需要两个:less、less-loader
cnpm install less less-loader -D
2、 在webpack.config.js中添加loader
6、 按需引入组(局部引入)
1、 安装babel-plugin-component
cnpm install babel-plugin-component -D
2、 配置.babelrc文件
![](/assets/blank.gif)
![](/assets/blank.gif)
"plugins": [["component", [{"libraryName": "element-ui","styleLibraryName": "theme-default"}]]]
View Code
3、只引入需要的插件
转载于:https://www.cnblogs.com/xuanan/p/7868688.html
Elment UI的使用说明相关推荐
- vue + elment ui打印表格数据
vue + elment ui打印表格数据 主要的原理就是 在vue项目中 通过调用浏览器自带的打印功能,完成对table数据的打印 解决表格错位 以及elment ui 双重表头的问题 封装一下打印 ...
- elment ui 时间组件(el-date-picker)限制只能选择当前时间之前的时间(包括时分秒的限制)
elment ui 时间组件(el-date-picker)限制只能选择当前时间之前的时间(包括时分秒的限制) 先上效果图: 如图当前是2022-04-07 10:43; 当前时间以后的时间不让选择, ...
- Elment ui中el-table 实现表格拖拽
Element ui el-table拖拽 拖动排序可对表格行进行拖拽排序 1.下载 npm install sortablejs --save 2.引用 import Sortable from & ...
- 设置elment ui plus 的el table的边框线
:**代码 设置类名,给奇偶行设置类名 const tableRowClassName = ({ rowIndex }) => {if (rowIndex % 2 === 0) {return ...
- elment ui 修改时间选择器的宽度及高度
一.html代码如下:用一个div包裹el-date-picker <div class="date-box"><el-date-pickerv-model=&q ...
- elment ui table 点击上下移动表格
点击按钮传入,下标 <el-buttonsize="mini"type="text"icon="el-icon-top"@click= ...
- el-ment ui 给el-table的el-table-column表头前添加红色*号
添加红色*号 <template><el-table :header-cell-class-name="mustAdd"></el-table> ...
- 如何解决elment ui 偶发性图标icon乱码问题
一般情况是因为sass版本低导致的我们只需要升级下sass版本就好了 升级sass.配置vue.config.js 先卸载之前版本sass sass npm uninstall sass npm in ...
- 【Vue.js】Vue.js中常用的UI组件库和Vue Router
1.Vue生态中常用的UI组件库 1. vant 介绍 轻量级.可靠的移动端 Vue 组件库 有赞前端团队出品 GitHub地址:https://github.com/youzan/vant 特性 拥 ...
最新文章
- 烽火18台系列之十一:刚需中的刚需——网站篡改监控
- IDEA报错解决:Error:(33, 35) java: -source 7 中不支持 lambda 表达式 (请使用 -source 8 或更高版本以启用 lambda 表达式)
- 通过Auto Layout深入了解SizeClasses的好处和使用
- Java基本语法——(用于日后复习)
- htpdate代替ntpdate同步时间
- 2d 蓝图_“蓝图”卷积--对深度可分离卷积的再思考
- java接口中多继承的问题
- 乐佰小迪智能机器人怎么使用_425台云洲智能水面救生机器人在山东寿光投入使用...
- 怎么创建数据表的实体类和业务类_SSM搭建二手市场交易平台(二):数据表设计...
- python数据库增删改查_python对数据库mysql的操作(增删改查)
- php去掉省市区,省市区后面的字符隐藏的php代码
- 笔记本电脑怎么拆开后盖_新手怎么拆解笔记本?笔记本拆机注意事项 (全文)
- win10关机后cpu风扇还在转_win10关机风扇一直转 指示灯亮怎么办_win10关机风扇还转指示灯亮的解决方法...
- python转义字符\r的使用
- explore exploit
- xp计算机找不到音量调节,WinXP电脑没声音且小喇叭不见了如何解决?
- 双系统启动界面自定义美化设置
- Hadoop大数据单词统计
- dda算法控制电机_插补计算原理与速度控制.DOC
- 无乳糖食物的全球与中国市场2022-2028年:技术、参与者、趋势、市场规模及占有率研究报告