您的位置:首页 > 产品设计 > UI/UE

【PC端vue ui框架学习】vue项目如何使用基于vue的UI框架Element

2017-12-13 02:30 1381 查看
看了下iView之后,顺便看了看同样基于vuejs的ui框架Element,那么在vue项目中应该如何使用Element呢?以下做简单的记录。

官网定义:Element,一套为开发者、设计师和产品经理准备的基于 Vue 2.0 的桌面端组件库

首先安装Element:

$ npm install element-ui --save
在main.js中添加如下代码:

import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'

Vue.use(ElementUI)
完成以上步骤,即可在项目中使用Element。

举例:在项目中使用Element提供的Carousel轮播图组件。

代码如下:
<template>
<div class="hello">
<el-carousel :interval="2000" type="card" height="100px">
<el-carousel-item v-for="item in pic" :key="item">
<img class="carousel-img" :src="item.url">
</el-carousel-item>
</el-carousel>
</div>
</template>

<script type="text/ecmascript-6">
export default {
data() {
return {
pic: [
{
url: 'http://www.sd.xinhuanet.com/news/yule/2017-07/07/1121280192_14993928268411n.jpeg'
},
{
url: 'http://pic.nen.com.cn/500/15/34/56/15345682_610838.jpg'
},
{
url: 'http://b.hiphotos.baidu.com/zhidao/pic/item/9825bc315c6034a8e7235341ce13495408237629.jpg'
},
{
url: 'http://b.hiphotos.baidu.com/image/pic/item/64380cd7912397dd682835d65382b2b7d1a2878b.jpg'
}
]
}
},
create() {
console.log(this.data.pic)
}
}
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
.carousel-img {
width:100%;
height:100px;
}
</style>
运行结果:



Element官网:http://element.eleme.io/#/zh-CN
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: