在上一篇文章当中,我写了如何在HTML5当中引入Vue,以及Vue的快速入门,那么本次我们一起来学习一下,如何在使用了vue以后,如何使用element组件。
element是由饿了么基于vue开发的一堆组键,我们需要使用的时候,直接去element官网复制代码即可官网链接(element中文官网)。
这里我直接给一个模板,可以直接复制去使用
代码如下:
DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<link rel="stylesheet" href="https://cdn.staticfile.org/element-ui/2.15.9/theme-chalk/index.css">
head>
<body>
<div id="app">
{{info}}
div>
body>
<script src="https://unpkg.com/vue@2/dist/vue.js">script>
<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 {
<!-- 这里是放所有数据的地方,与vue有一点区别 -->
info:"HelloEleUI"
}
},
methods:{
<!-- 所有方法都放这里 -->
}
})
script>
html>
DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<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>
<el-menu style="width: 1200px;margin: 0 auto" mode="horizontal"
background-color="#0aa1ed" text-color="#fff"
active-text-color="#f00" @select="handleSelect">
<el-menu-item index="1">精彩活动el-menu-item>
<el-menu-item index="2">精品女装el-menu-item>
<el-menu-item index="3">品牌男装el-menu-item>
<el-menu-item index="4">母婴产品el-menu-item>
<el-menu-item index="5">数码科技el-menu-item>
el-menu>
el-row>
el-header>
<el-main style="width: 1200px;margin: 0 auto">
<el-row gutter="20">
<el-col span="18">
<el-carousel height="300px">
<el-carousel-item>
<img src="imgs/b1.jpg" width="100%" height="100%">
el-carousel-item>
<el-carousel-item>
<img src="imgs/b2.jpg" width="100%" height="100%">
el-carousel-item>
<el-carousel-item>
<img src="imgs/b3.jpg" width="100%" height="100%">
el-carousel-item>
el-carousel>
el-col>
<el-col span="6">
<el-card>
<h3>
<i style="font-weight: bold"
class="el-icon-trophy">销量最高i>
h3>
<el-divider>el-divider>
<el-table :data="topArr">
<el-table-column type="index" label="排名">el-table-column>
<el-table-column prop="title" label="商品名">el-table-column>
<el-table-column prop="saleCount" label="销量">el-table-column>
el-table>
el-card>
el-col>
el-row>
<el-row gutter="20">
<el-col style="margin: 10px 0" span="6" v-for="p in productArr">
<el-card>
<img :src="p.url" width="100%">
<p >{{p.title}}p>
<p style="font-size: 12px">¥{{p.price}} <s>{{p.oldPrice}}s>
<span style="float: right">销量:{{p.saleCount}}件span>
p>
el-card>
el-col>
el-row>
el-main>
el-container>
div>
body>
<script src="https://cdn.staticfile.org/vue/2.6.14/vue.min.js">script>
<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 {
topArr:[{title:"小米手机",saleCount:1432},
{title:"安踏拖鞋",saleCount:987},
{title:"李宁毛巾",saleCount:957}],
productArr:[{title:"森马牛仔裤女宽松慢跑裤运动风2022春季新款",price:233,oldPrice:598,url:"imgs/a.jpg",saleCount:2342},
{title:"茵曼马甲连衣裙两件套春季新款娃娃领色织格长袖背心裙套装",price:233,oldPrice:598,url:"imgs/b.jpg",saleCount:2342},
{title:"雪中飞墨绿色短袖t恤女夏2022新款纯棉半袖打底体恤夏季",price:233,oldPrice:598,url:"imgs/c.jpg",saleCount:2342},
{title:"【佟丽娅同款】鸭鸭明星同款羽绒服2021年冬季新款时尚",price:233,oldPrice:598,url:"imgs/d.jpg",saleCount:2342},
{title:"BEASTER小恶魔鬼脸明星同款夹克毛绒保暖加厚字母印花",price:233,oldPrice:598,url:"imgs/e.jpg",saleCount:2342},
{title:"香影毛呢外套女中长款2021年冬季新款气质韩版娃娃领",price:233,oldPrice:598,url:"imgs/f.jpg",saleCount:2342},
{title:"SEMIR森马商场同款打底针织毛衣纯色高领新品显瘦",price:233,oldPrice:598,url:"imgs/g.jpg",saleCount:2342},
{title:"美特斯邦威女MTEE 贺岁系列中长款风衣736598",price:233,oldPrice:598,url:"imgs/h.jpg",saleCount:2342},
{title:"imone2021秋款黑色小西装外套女韩版学生宽松学",price:233,oldPrice:598,url:"imgs/i.jpg",saleCount:2342},
{title:"BEASTER 小恶魔明星同款保暖长袖街头潮流连帽卫",price:233,oldPrice:598,url:"imgs/j.jpg",saleCount:2342},
{title:"憨厚皇后100%绵羊皮2021秋海宁真皮皮衣女长款修",price:233,oldPrice:598,url:"imgs/k.jpg",saleCount:2342},
{title:"美特斯邦威高腰牛仔裤女宽松小脚新款春秋彩色",price:233,oldPrice:598,url:"imgs/a.jpg",saleCount:2342}]
}
},
methods:{
handleSelect(key,keyPath){
console.log(key);
}
}
})
script>
html>
讲了element的入门,以及示例,也给了element的官网地址,给了一个基本模板,在下一文章当中,我将说明element的一部分组件。