1.0.6 • Published 6 years ago
vue-u-carousel v1.0.6
vue图片轮播插件
使用方法
components组件方式
下载./lib/vue-carousel.vue文件
import VueUCarousel from '~/components/vue-u-carousel.vue'
components:{
'vue-u-carousel':VueUCarousel
}
插件方式
npm install vue-u-carousel
1.vue项目
import VueUCarousel from 'vue-u-carousel'
Vue.use(VueUCarousel)
<template>
<section>
<vue-u-carousel :CarouselHeight="carouselH" :controlBtn="controlBtn" :imgArray="imgArray"></vue-u-carousel>
</section>
</template>
<script>
export default {
data(){
return{
carouselH:'300px', //高度
controlBtn:false //是否添加左右控制btn
/*
参数说明:
scr:图片地址
href:图片a链接,无链接设置为#
btn:在图片中自定义div区域使用a连接跳转 classname:类名,href:链接,若不使用btn:[]
使用btn时一定要根据类名,定义样式
此为默认参数
imgArray:[
{
key: 1,
src: 'https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1521880846160&di=1da91620edd8082142e5802d4a4f967c&imgtype=0&src=http%3A%2F%2Fpic1.win4000.com%2Fwallpaper%2F4%2F57b6a7f82383b.jpg',
alt: 'p1.png',
href: 'http://www.baidu.com',
btn: []
},
{
key: 2,
src: 'https://ss0.baidu.com/94o3dSag_xI4khGko9WTAnF6hhy/image/h%3D300/sign=d5a029d7befb4316051f7c7a10a54642/ac345982b2b7d0a2e4394d81c7ef76094b369a3e.jpg',
alt: 'p2.png',
href: '#',
btn: [{key: 1, text: '去百度', classname: 'onimgbtn', href: 'http://www.baidu.com'}, {
key: 2,
classname: 'onimgbtn1',
href: 'http://www.baidu.com'
}]
}
]
*/
}
}
}
</script>
<style></style>
2.nuxt项目
请参考https://zh.nuxtjs.org/guide/plugins
新建./plugins/vue-u-carousel.js
import Vue from 'vue'
import VueCarousel from 'vue-u-carousel'
Vue.use(VueCarousel);
在./nuxt.config.js中:
...other code
plugins: [
{src: '~/plugins/vue-u-carousel.js', ssr: false}
]
...other code
build:{
vendor: ['vue-u-carousel']
}