ElementUI官方地址:https://element.eleme.cn/2.11/#/zh-CN

1.初期准备

  首先我们准备几个基本的样式文件:normalize.css 和 base.css

  normalize.css:一个CSS RESET(样式重置)的文件,下载地址:https://necolas.github.io/normalize.css/,具体可以搜索 "reset.css和normalize.css"

  base.css:根据项目或个人需求定义的一些基本样式,这里我们只简单定义一下

  (一般我们将静态资源文件放在 /src/assets目录中)

*{
outline: none;
} html,
body {
margin:;
padding:;
width: 100%;
height: 100%;
} textarea {
resize: none !important;
} input[type="text"]:disabled {
background: 0 0!important;
color: #c2c2c2;
cursor: not-allowed;
user-select: none;
} .hidden {
display: none;
} .unselect {
-moz-user-select: none;
-webkit-user-select: none;
-ms-user-select: none;
-khtml-user-select: none;
user-select: none;
} #app {
padding: 0px;
margin: 0px;
height: 100%;
} #el-aside{
width: 220px !important;
} .el-menu.el-menu-vertical-demo{
border-bottom: none;
height: 100%;
} .el-menu.el-menu-vertical-demo > li{
text-align: left;
}

2.快速搭建

  引入依赖命令:cnpm i element-ui -S

  再package.json文件中可以看到引入依赖的信息,表示引入依赖成功

  

  接下来要在 main.js 中全局引入 Element,代码如下

import Vue from 'vue';
import App from './App';
import router from './router';
import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';
import './assets/css/normalize.css';
import './assets/css/base.css'; Vue.config.productionTip = false;
Vue.use(ElementUI); new Vue({
el: '#app',
router,
components: { App },
template: '<App/>'
});

2.使用Container容器布局

  根据官方提供案例,修改 App.vue 文件

<template>
<el-container id="app">
<el-header>Header</el-header>
<el-container>
<el-aside width="200px">Aside</el-aside>
<el-main>Main</el-main>
</el-container>
<el-footer>Footer</el-footer>
</el-container>
</template> <script>
export default {
name: 'App'
};
</script> <style>
.el-header,
.el-footer {
background-color: #b3c0d1;
color: #333;
text-align: center;
line-height: 60px;
} .el-aside {
background-color: #d3dce6;
color: #333;
text-align: center;
line-height: 200px;
} .el-main {
background-color: #e9eef3;
color: #333;
text-align: center;
line-height: 160px;
} body > .el-container {
margin-bottom: 40px;
} .el-container:nth-child(5) .el-aside,
.el-container:nth-child(6) .el-aside {
line-height: 260px;
} .el-container:nth-child(7) .el-aside {
line-height: 320px;
}
</style>

3.实现导航栏

  修改 App.vue 文件

<template>
<el-container id="app">
<el-header>Header</el-header>
<el-container>
<el-aside id="el-aside">
<el-menu default-active="1" class="el-menu-vertical-demo" background-color="#545c64" text-color="#fff" active-text-color="#ffd04b">
<el-menu-item index="1">
<i class="el-icon-menu"></i>
<span>处理中心</span>
</el-menu-item>
<el-submenu index="2">
<template slot="title">
<i class="el-icon-s-unfold"></i>
<span>我的工作台</span>
</template>
<el-menu-item index="2-1">
<i class="el-icon-arrow-right"></i>
<span>选项1</span>
</el-menu-item>
<el-menu-item index="2-2">
<i class="el-icon-arrow-right"></i>
<span>选项2</span></el-menu-item>
<el-menu-item index="2-3">
<i class="el-icon-arrow-right"></i>
<span>选项3</span>
</el-menu-item>
</el-submenu>
<el-menu-item index="3">
<i class="el-icon-message-solid"></i>
<span>消息中心</span>
</el-menu-item>
</el-menu>
</el-aside>
<el-main>Main</el-main>
</el-container>
<el-footer>Footer</el-footer>
</el-container>
</template> <script>
export default {
name: 'App'
};
</script> <style>
.el-header,
.el-footer {
background-color: #b3c0d1;
color: #333;
text-align: center;
line-height: 60px;
} .el-aside {
background-color: #d3dce6;
color: #333;
text-align: center;
line-height: 200px;
} .el-main {
background-color: #e9eef3;
color: #333;
text-align: center;
line-height: 160px;
} body > .el-container {
margin-bottom: 40px;
} .el-container:nth-child(5) .el-aside,
.el-container:nth-child(6) .el-aside {
line-height: 260px;
} .el-container:nth-child(7) .el-aside {
line-height: 320px;
}
</style>

  实现效果图

  

Vue学习笔记-使用ElementUI的更多相关文章

  1. Vue学习笔记-2

    前言 本文非vue教程,仅为学习vue过程中的个人理解与笔记,有说的不正确的地方欢迎指正讨论 1.computed计算属性函数中不能使用vm变量 在计算属性的函数中,不能使用Vue构造函数返回的vm变 ...

  2. Vue学习笔记-1

    前言 本文不是Vue.js的教程,只是一边看官网Vue的教程文档一边记录并总结学习过程中遇到的一些问题和思考的笔记. 1.vue和avalon一样,都不支持VM初始时不存在的属性 而在Angular里 ...

  3. vue 学习笔记(二)

    最近公司赶项目,一直也没时间看 vue,之前看下的都快忘得差不多了.哈哈哈,来一起回顾一下vue 学习笔记(一)后,继续向下看嘛. #表单输入绑定 基础用法 v-model 会忽略所有表单元素的 va ...

  4. vue学习笔记之:为何data是一个方法

    vue学习笔记之:为何data是一个方法 在vue开发中,我们可以发现,data中的属性值是在function中return出来的.可为何data必须是一个函数呢?我们先看官方的解释: 当一个组件被定 ...

  5. vue学习笔记(八)组件校验&通信

    前言 在上一章博客的内容中vue学习笔记(七)组件我们初步的认识了组件,并学会了如何定义局部组件和全局组件,上一篇内容仅仅只是对组件一个简单的入门,并没有深入的了解组件当中的其它机制,本篇博客将会带大 ...

  6. vue学习笔记(九)vue-cli中的组件通信

    前言 在上一篇博客vue学习笔记(八)组件校验&通信中,我们学会了vue中组件的校验和父组件向子组件传递信息以及子组件通知父组件(父子组件通信),上一篇博客也提到那是对组件内容的刚刚开始,而本 ...

  7. vue学习笔记(十)路由

    前言 在上一篇博客vue学习笔记(九)vue-cli中的组件通信内容中,我们学习组件通信的相关内容和进行了一些组件通信的小练习,相信大家已经掌握了vue-cli中的组件通信,而本篇博客将会带你更上一层 ...

  8. AntDesign vue学习笔记(七)Form 读写与图片上传

    AntDesign Form使用布局相比传统Jquery有点繁琐 (一)先读写一个简单的input为例 <a-form :form="form" layout="v ...

  9. Vue学习笔记十三:Vue+Bootstrap+vue-resource从接口获取数据库数据

    目录 前言 SpringBoot提供后端接口 Entity类 JPA操作接口 配置文件 数据库表自动映射,添加数据 写提供数据的接口 跨域问题 前端修改 效果图 待续 前言 Vue学习笔记九的列表案例 ...

随机推荐

  1. Flask 第二篇

    Flask 中的 Render Redirect HttpResponse 1.Flask中的HTTPResponse 在Flask 中的HttpResponse 在我们看来其实就是直接返回字符串 2 ...

  2. python 替换字符串的方法replace()、正则re.sub()

    一.replace()函数1用字符串本身的replace方法: a = 'hello word' b = a.replace('word','python') print b   1 2 3 二.re ...

  3. 说说iOS与内存管理(上)

    http://www.cocoachina.com/ios/20150625/12234.html 说起内存管理,看似老生常谈,而真正掌握内存管理的核心其实并不简单.ARC/MRR以及“谁分配谁就负责 ...

  4. ural 1519 Formula 1(插头dp)

    1519. Formula 1 @ Timus Online Judge 干了一天啊!!!插头DP入门. 代码如下: #include <cstdio> #include <cstr ...

  5. Collections.sort list内部排序

    public class ComparatorUser implements Comparator{   public int compare(Object arg0, Object arg1) {  ...

  6. Datamation Index

    Datamation Index     Understand how to handle big data and improve organizational agility to support ...

  7. Python基础:28正则表达式

    一:概述 正则表达式(RE)为高级文本模式匹配,以及搜索-替代等功能提供了基础.正则表达式(RE)是一些由字符和特殊符号组成的字符串,它们能匹配多个字符串.Python通过标准库的re模块支持正则表达 ...

  8. caffe 下一些参数的设置

    weight_decay防止过拟合的参数,使用方式:1 样本越多,该值越小2 模型参数越多,该值越大一般建议值:weight_decay: 0.0005 lr_mult,decay_mult关于偏置与 ...

  9. 2018-2-13-win10-uwp-获得Slider拖动结束的值

    title author date CreateTime categories win10 uwp 获得Slider拖动结束的值 lindexi 2018-2-13 17:23:3 +0800 201 ...

  10. canvas实现碰壁反弹(单个小方块)

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...