轮播效果是第一页是显示 side1 和side2,然后 转到下一页是空白页,并不是第一页显示side1,第二页显示side2 ,哪里出错了?
代码:
<template>
<div>
<swiper :options="swiperOption" ref="mySwiper">
<!-- 幻灯内容 -->
<swiper-slide>slide1</swiper-slide>
<swiper-slide>slide2</swiper-slide>
<!-- 以下控件元素均为可选 -->
<div class="swiper-pagination" slot="pagination"></div>
<div class="swiper-button-prev" slot="button-prev"></div>
<div class="swiper-button-next" slot="button-next"></div>
<div class="swiper-scrollbar" slot="scrollbar"></div>
</swiper>
</div>
</template>
<script>
import { swiper, swiperSlide } from 'vue-awesome-swiper'
export default{
components: {
swiper,
swiperSlide
},
data () {
return {
swiperOption: {
notNextTick: true,
// loop: true,
pagination: '.swiper-pagination',
slidesPerView: 'auto',
centeredSlides: true,
autoplay: 3000,
paginationClickable: true,
spaceBetween: 10,
onSlideChangeEnd: swiper => {
this.page = swiper.realIndex + 1
this.index = swiper.realIndex
}
}
}
},
computed: {
swiper () {
return this.$refs.mySwiper.swiper
}
},
mounted () {
// this.swiper.slideTo(0, 0, false)
}
}
</script>
回调函数没走的原因是,现在swiper用的4.0版本,要on:{init:xxx,slideChangeTransitionEnd:xxx},
很多方法都改掉了,要去看官方文档