slider.vue中的部分代码
props: {
loop: {
type: Boolean,
default: true
},
autoPlay: {
type: Boolean,
default: false
},
interval: {
type: Number,
default: 1000
}
},
methods中的部分代码
_setSliderWidth (isResize) {
this.children = this.$refs.sliderGroup.children
let width = 0
let sliderWidth = this.$refs.slider.clientWidth
for (let i = 0; i < this.children.length; i++) {
let child = this.children[i]
addClass(child, 'slider-item')
child.style.width = sliderWidth + 'px'
width += sliderWidth
}
if (this.loop && !isResize) {
width += 2 * sliderWidth
}
this.$refs.sliderGroup.style.width = width + 'px'
console.log('图片个数:' + (width / sliderWidth))
},
_initSlider () {
this.slider = new BScroll(this.$refs.slider, {
scrollX: true,
scrollY: false,
momentum: false,
snap: true,
snapLoop: this.loop,
snapThreshold: 0.3,
snapSpeed: 400
})
感觉都对就是轮播到最后一张时没图片了,而且无法循环播,好郁闷呀,老师拜托了登录后可查看更多问答,登录/注册