<div><a href=""><img src=" rel="external nofollow" rel="external nofollow" rel="external nofollow" "/></a></div> <div><a href=""><img src=" rel="external nofollow" rel="external nofollow" rel="external nofollow" "/></a></div> <div><a href=""><img src=" rel="external nofollow" rel="external nofollow" rel="external nofollow" "/></a></div>
<!--js-->
data:{
swipeInfo:[{
href:"http://www.baidu.com",
imgSrc:""
},{
href:"http://www.baidu.com",
imgSrc:""
},{
href:"http://www.baidu.com",
imgSrc:""
}]
},
components: {
'swipe-module': require('pagination-swipe'),
},
<!--html--> <swipe-module :swipeinfo="swipeInfo"></swipe-module>
<!--template.html-->
<div v-el:swipe class='swipe bar-slider'>
<div class='swipe-wrap'>
<div v-for="item in swipeinfo"><a :href=item.href><img :src=item.imgSrc /></a></div>
</div>
<!-- 分页 -->
<div class="pagination">
<span class="swipe-pagination-switch swipe-active-switch" @click="slideToCur(0)"></span>
<span class="swipe-pagination-switch" @click="slideToCur($index+1)" v-for="item in slideNum"></span>
</div>
</div>
//index.js
require('./style.less');
var Swipe = require('swipe');
Vue.component('pagination-swipe',{
props: ['swipeinfo'],
template: require('raw!./template.html'),
data: function() {
return {
mySwipe: {},
slideNum: {},
};
},
ready: function() {
var self = this;
//获取子组件中分页小圈圈
var slides = self.$els.swipe.getElementsByClassName('swipe-pagination-switch');
self.mySwipe = new Swipe(self.$els.swipe, {
startSlide: 0,
continuous: true,
speed: 1000,
auto: 4000,
stopPropagation: false,
callback: function(index, elem) {
//渲染分页小圈圈
for (var i = 0; i < slides.length; i++) {
if (i != index) {
slides[i].style.opacity = "0.2";
slides[i].style.background = "#000";
} else {
slides[index].style.opacity = "1";
slides[index].style.background = "#ee3a4a";
}
}
},
});
self.slideNum = self.mySwipe.getNumSlides() - 1;
},
methods: {
//点击底部小圈圈,跳到其所对应页
slideToCur: function(index) {
var self = this;
self.mySwipe.slide(index, 300);
},
}
});
<!--style.less-->
.swipe {
overflow: hidden;
visibility: hidden;
position: relative;
height: 200/@rem;
.swipe-wrap {
position: relative;
overflow: hidden;
height: 100%;
div {
float: left;
width: 100%;
position: relative;
margin: 0;
a {
width: 100%;
height: 100%;
background-position: center 0;
background-repeat: no-repeat;
background-color: transparent;
display: block;
img {
width: 100%;
height: 100%;
}
}
}
}
.pagination {
text-align: center;
position: relative;
bottom: 40/@rem;
cursor: pointer;
}
.swipe-pagination-switch {
content: "";
display: inline-block;
width: 8px;
height: 8px;
border-radius: 100%;
background: #000;
opacity: 0.2;
margin: 0 8px;
z-index: 10;
&:first-child {
background: #ee3a4a;
}
}
.swipe-active-switch {
opacity: 1;
}
}
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有