一、 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、示例:

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)
})

  3、 在webpack.config.js中添加loader

    1、 CSS样式和字体图标都需要由相应的loader来加载,所以需要style-loader、css-loader

    2、默认并没有style-loader模块,所以需要单独安装

      cnpm install style-loader --save-dev

    3、示例

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.html
module.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
})
])
}

    4、 使用组件

<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="" class="grid">welcome</el-col>
<el-col :span="" class="grid">to</el-col>
<el-col :span="" class="grid">itany</el-col>
<el-col :span="" class="grid">网博</el-col>
</el-row>
<el-row>
<el-col :span="" class="grid">welcome</el-col>
<el-col :span="" 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

<template>
<el-date-picker
v-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

<template>
<el-upload
class="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文件

 "plugins": [["component", [
{
"libraryName": "element-ui",
"styleLibraryName": "theme-default"
}
]]]

      3、只引入需要的插件

Elment UI的使用说明的更多相关文章

  1. 2 Elment Ui 日期选择器 格式化问题

    Elment Ui 日期选择器 格式化问题 在前后端联调过程中 我们常常会遇到日期无法被反序列化 这个问题 会有点头疼 下面以我这边为例 后端使用的是springboot 默认集成了jackjson ...

  2. SpringBoot 整合文件上传 elment Ui 上传组件

    SpringBoot 整合文件上传 elment Ui 上传组件 本文章记录 自己学习使用 侵权必删! 前端代码 博主最近在学 elment Ui 所以 前端使用 elmentUi 的 upload ...

  3. JEECG-Swagger UI的使用说明

    一.代码生成 (此步骤为代码生成器的使用,如不清楚请查阅相关文档视频) 1.进入菜单[在线开发]-->[Online表单开发],选中一张单表/主表,点击代码生成按钮. 2.弹出页面中填写代码生成 ...

  4. elment ui 图片上传遇到的一些问题

    图片上传返回200,message显示请上传图片 注意上图中的name字段要和服务器接受的name相同,这里我们是imgfile,默认name不是这个,所以要在el-upload组件上设置name属性 ...

  5. vue 基于elment UI tree 组件实现带引导、提示线

    实现样式 准备工作,先实现 树状组件的基本样式 <span style="height:500px; display:block; overflow-y:auto;" cla ...

  6. Vue(十八)Element UI

    Elment UI 1. 简介 Element UI是饿了么团队提供的一套基于Vue2.0的组件库,可以快速搭建网站,提高开发效率 ElementUI PC端 MintUI 移动端 [官网](http ...

  7. vue学习记录

    vue中常用的指令 v-model 双向数据绑定,一般用于表单元素 v-for 对数组或对象进行循环操作,使用的是v-for <!-- 普通循环 --><li v-for=" ...

  8. Vue系列(三):组件及数据传递、路由、单文件组件、vue-cli脚手架

    上一篇:Vue系列(二):发送Ajax.JSONP请求.Vue生命周期及实例属性和方法.自定义指令与过渡 一. 组件component 1. 什么是组件? 组件(Component)是 Vue.js ...

  9. Vue知识点精简汇总

    一. 组件component 1. 什么是组件? 组件(Component)是 Vue.js 最强大的功能之一.组件可以扩展 HTML 元素,封装可重用的代码组件是自定义元素(对象) 2. 定义组件的 ...

随机推荐

  1. 关于Unity中调试C#的方法

    1.断点输出语句 在感觉有问题的地方的上下文写一些输出语句,如果控制台只有输出上文,没有输出下文,那么可以知道,上下文之间的语句有问题,因为下文没执行到,没有输出语句. Debug.Log(" ...

  2. dlib python 人脸检测与关键点标记

    http://blog.csdn.net/sunmc1204953974/article/details/49976045 人脸检测 #coding=utf-8 # -*- coding: utf-8 ...

  3. 第二百四十九节,Bootstrap附加导航插件

    第二百四十九节,Bootstrap附加导航插件 学习要点: 1.附加导航插件 本节课我们主要学习一下 Bootstrap 中的附加导航插件 一.附加导航 注意:此插件要使用 bootstrap3.0. ...

  4. 【BZOJ】1685: [Usaco2005 Oct]Allowance 津贴(贪心)

    http://www.lydsy.com/JudgeOnline/problem.php?id=1685 由于每个小的都能整除大的,那么我们在取完大的以后(不超过c)后,再取一个最小的数来补充,可以证 ...

  5. ORACLE之常用FAQ V1.0

    [B]第一部分.SQL&PL/SQL[/B][Q]怎么样查询特殊字符,如通配符%与_[A]select * from table where name like 'A\_%' escape ' ...

  6. selenium基础框架的封装(Python版)这篇帖子在百度关键词搜索的第一位了,有图为证,开心!

    百度搜索结果页地址:https://www.baidu.com/s?ie=utf-8&f=3&rsv_bp=1&rsv_idx=1&tn=baidu&wd=se ...

  7. 剑指 offer set 11 最小的K个数

    总结 1. 假如允许修改给定数组, 那么通过快排的子过程, 可以在 o(n) 时间复杂度内得出结果. 2. 对于海量数据和不允许修改的数据, 通过最小堆的方式更好, 通过维持一个大小为 K 的最小堆

  8. JQZoom

    UI采用jQuery插件 习惯网购的朋友都深有体会.大部分皇冠级淘宝卖家都是图片控.京东商城的放大图效果也是吸引消费者的法宝之一.京东商城产品展示页支持多图切换并放大代码,放大功能的核心代码为jQzo ...

  9. jquery表单验证插件 jquery.form.js ------转载

    Form插件,支持Ajax,支持Ajax文件上传,功能强大,基本满足日常应用. 1.JQuery框架软件包下载 文件: jquery.rar 大小: 29KB 下载: 下载 2.Form插件下载 文件 ...

  10. LAMP集群项目五 nfs分发文件到服务器

    前边已经配置了免密钥登录,现在脚本直接调用scp即可 ./etc/init.d/functions ] then echo “argv is not correct” exit fi for ip i ...