前言
在之前的文章当中我写了vue,element相关的基础,本次实战,用element写一个页面。
一、ui
本次实现的页面ui
二、步骤
1.分析
ui当中分为上下布局,所以我们需要去element官网找到布局容器
 {
console.log(key, keyPath);
},
handleClose(key, keyPath) {
console.log(key, keyPath);
}
}
}
</script>
中间为表格
<template>
<el-table
:data="tableData"
style="width: 100%">
<el-table-column
label="日期"
width="180">
<template slot-scope="scope">
<i class="el-icon-time"></i>
<span style="margin-left: 10px">{{ scope.row.date }}</span>
</template>
</el-table-column>
<el-table-column
label="姓名"
width="180">
<template slot-scope="scope">
<el-popover trigger="hover" placement="top">
<p>姓名: {{ scope.row.name }}</p>
<p>住址: {{ scope.row.address }}</p>
<div slot="reference" class="name-wrapper">
<el-tag size="medium">{{ scope.row.name }}</el-tag>
</div>
</el-popover>
</template>
</el-table-column>
<el-table-column label="操作">
<template slot-scope="scope">
<el-button
size="mini"
@click="handleEdit(scope.$index, scope.row)">编辑</el-button>
<el-button
size="mini"
type="danger"
@click="handleDelete(scope.$index, scope.row)">删除</el-button>
</template>
</el-table-column>
</el-table>
</template>
<script>
export default {
data() {
return {
tableData: [{
date: '2016-05-02',
name: '王小虎',
address: '上海市普陀区金沙江路 1518 弄'
}, {
date: '2016-05-04',
name: '王小虎',
address: '上海市普陀区金沙江路 1517 弄'
}, {
date: '2016-05-01',
name: '王小虎',
address: '上海市普陀区金沙江路 1519 弄'
}, {
date: '2016-05-03',
name: '王小虎',
address: '上海市普陀区金沙江路 1516 弄'
}]
}
},
methods: {
handleEdit(index, row) {
console.log(index, row);
},
handleDelete(index, row) {
console.log(index, row);
}
}
}
</script>
2.完整代码
上述分析是找到我们需要copy的地方,还需要进行合并修改,在根据ui内容给一个css样式和一些文字及大功告成
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<!-- import CSS -->
<link rel="stylesheet" href="https://cdn.staticfile.org/element-ui/2.15.9/theme-chalk/index.css">
</head>
<body>
<div id="app">
<el-container>
<el-header height="50px" style="padding: 0">
<div style="width: 100%;background-color: #0aa1ed;height: 50px;">
<el-row gutter="20">
<el-col span="12">
<span style="font-size: 20px;color: white;font-weight: bold; margin-left: 20px;line-height: 50px">CoolShark商城后台管理系统</span>
</el-col>
<el-col span="12">
<p style="color: white;font-size: 12px;float: right;margin: 0 20px 0 0;line-height: 50px">欢迎范传奇回来<a href="">退出登录</a></p>
</el-col>
</el-row>
</div>
</el-header>
<el-container>
<el-aside width="300px" style="height: 500px">
<el-menu
default-active="2"
class="el-menu-vertical-demo"
@open="handleOpen"
@close="handleClose">
<el-submenu index="1">
<template slot="title">
<i class="el-icon-location"></i>
<span>分类管理</span>
</template>
<el-menu-item index="1-1">分类列表</el-menu-item>
<el-menu-item index="1-2">添加分类</el-menu-item>
</el-submenu>
<el-submenu index="2">
<template slot="title">
<i class="el-icon-location"></i>
<span>轮播图管理</span>
</template>
<el-menu-item index="2-1">轮播图列表</el-menu-item>
<el-menu-item index="2-2">添加轮播图</el-menu-item>
</el-submenu>
<el-submenu index="3">
<template slot="title">
<i class="el-icon-location"></i>
<span>商品管理</span>
</template>
<el-menu-item index="1-1">商品列表</el-menu-item>
<el-menu-item index="1-2">添加商品</el-menu-item>
</el-submenu>
</el-menu>
</el-aside>
<el-main>
<el-table
:data="arr"
style="width: 100%">
<el-table-column type="index" label="编号"></el-table-column>
<el-table-column
prop="index"
label="编号">
</el-table-column>
<el-table-column
prop="classification"
label="分类">
</el-table-column>
<el-table-column label="操作">
<template slot-scope="scope">
<el-button
size="mini"
type="danger"
@click="handleDelete(scope.$index, scope.row)">删除</el-button>
</template>
</el-table-column>
</el-table>
</el-main>
</el-container>
</el-container>
</div>
</body>
<!-- import Vue before Element -->
<script src="https://unpkg.com/vue@2/dist/vue.js"></script>
<!-- import JavaScript -->
<script src="https://cdn.staticfile.org/element-ui/2.15.9/index.min.js"></script>
<script>
let v = new Vue({
el: '#app',
data: function() {
return {
arr:[
{classification:"精彩活动"},
{classification:"精品女装"},
{classification:"时尚男装"},
{classification:"医药健康"},
{classification:"数码科技"},
]
}
},
methods:{
}
})
</script>
</html>
总结
element不需要背,但是需要花时间去看懂,要用的时候,直接去官网进行copy修改即可。