赞
踩
我们学习VUE,知道它的核心思想式组件和数据驱动,但是每一个组件都需要自己编写模板,样式,添加事 件,数据等是非常麻烦的,
所以饿了吗推出了基于VUE2.0的组件库,它的名称叫做element-ui,提供了丰富的PC端组件
ElementUI官网: http://element-cn.eleme.io/#/zh-CN
注1:类似前端框架还有iview,
CDN导入
<link href="https://cdn.bootcss.com/element-ui/2.8.2/theme-chalk/index.css" rel="stylesheet">
<!-- 2. 引入vue和vue-router-->
<script src="https://cdn.bootcss.com/vue/2.6.10/vue.js"></script>
<!-- 未使用vue路由功能可不导入 -->
<script src="https://cdn.bootcss.com/vue-router/3.0.6/vue-router.js"></script>
<!-- 3. 引入ElementUI组件 -->
<script src="https://cdn.bootcss.com/element-ui/2.8.2/index.js"></script>
接下来我们演示一个elementUI实例
html 代码如下:
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>elementui入门</title> <!-- 1. 导入css --> <link href="https://cdn.bootcss.com/element-ui/2.8.2/theme-chalk/index.css" rel="stylesheet"> <!-- 2. 引入vue和vue-router--> <script src="https://cdn.bootcss.com/vue/2.6.10/vue.js"></script> <!-- 未使用vue路由功能可不导入 --> <script src="https://cdn.bootcss.com/vue-router/3.0.6/vue-router.js"></script> <!-- 3. 引入ElementUI组件 --> <script src="https://cdn.bootcss.com/element-ui/2.8.2/index.js"></script> <style> .el-row { margin-bottom: 20px; &:last-child { margin-bottom: 0; } } .el-col { border-radius: 4px; } .bg-purple-dark { background: #99a9bf; } .bg-purple { background: #d3dce6; } .bg-purple-light { background: #e5e9f2; } .grid-content { border-radius: 4px; min-height: 36px; } .row-bg { padding: 10px 0; background-color: #f9fafc; } </style> </head> <body> <div id="app"> <ul> <li> <h1>{{ts}}</h1> <p>传统html+vue+elementUI开发</p> <el-row> <el-col :span="24"> <div class="grid-content bg-purple-dark"> <el-button type="primary" v-on:click="doClick">主要按钮</el-button> </div> </el-col> </el-row> <el-row> <el-col :span="18"> <div class="grid-content bg-purple" style="height: 400px;">博客信息</div> </el-col> <el-col :span="6"> <div class="grid-content bg-purple-light" style="height: 400px;">分类管理</div> </el-col> </el-row> <el-row> <el-col :span="24"> <div class="grid-content bg-purple-dark">版权信息</div> </el-col> </el-row> </li> </ul> </div> </body> <script> var vm = new Vue({ el: "#app", data: function() { return { ts: new Date().getTime() } }, methods: { doClick: function() { console.log('doClick'); this.$alert('这是一段内容', '标题名称', { confirmButtonText: '确定', callback: action => { this.$message({ type: 'info', message: `action: ${ action }` }); } }); } } }); </script> </html>
效果如下:
谢谢大家,多多指教!!!
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。