|
2018年6月13日
引用
"better-scroll":
"^1.12.0",
现象:
- 可以轮播,但不能循环(不能从第一张往前翻,不能从最后一张往后翻)
- 按教程里给slider-group增加了2个slider的宽度,但他们出现在轮播图片的末尾(2个空白)
- 第一张图没有对应dot,第二张图对应第一个dot,以此类推
经过网友分享,我又重新整理了下面的问题,部分引用了网友答案
后经网友分享,发现0.1.15中可以正常运行,原来是better-scoll版本的问题,在新版本中,轮播图的bs对象需要这么配置(snap写在一个对象中):
- this.slider = new BScroll(this.$refs.slider, {
- scrollX: true,
- scrollY: false,
- momentum: false,
- snap: {
- loop: this.loop,
- threshold: 0.3,
- speed: 400
- },
- click: true
- })
还有一些小修改,可能是个人原因,也可能是版本差异,贴出来给大家一下:
- dot与图片不对应:
-
- this.slider.on('scrollEnd', () => {
- let pageIndex = this.slider.getCurrentPage().pageX
-
-
-
-
- this.currentPageIndex = pageIndex
-
- if (this.autoPlay) {
- clearTimeout(this.timer)
- this._play()
- }
- })
- _play() {
let pageIndex = this.currentPageIndex + 1 - //老版本有,新版删掉
if (this.loop) { pageIndex += 1 } this.timer = setTimeout(() => { //this.slider.goToPage(pageIndex, 0, 400)
this.slider.next()
//老版本是用的goToPage ,但是只到最后一张图片,不能继续轮播,我换成了next()问题就解决了 }, this.interval)
|