swiper 在turn.js不能滚动
生活随笔
收集整理的這篇文章主要介紹了
swiper 在turn.js不能滚动
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
這個問題,使用turn.js的同學一定遇到過,那怎么解決呢?
答案: 翻到對應包含swiper 的那頁,重新初始化swiper
假設這個是第3頁
<div class="page-container flipbook" id="magazine"><divv-for="(n, index) in 9":key="`phone_${index}`":class="`page${index}`"class="page"><component :is="`Page${index}`" :current="currentPage"> </component></div></div>我們綁定對應的currentPage,代表當前翻到第幾頁
$('#magazine').turn({width: 750,height: 961,elevation: 50,display: 'single',gradients: true,autoCenter: true,duration: 800,acceleration: true,// zoom: 0.1,page: self.page,when: {turned: function(e, page, view) {self.currentPage = page //獲取翻到當前第幾頁console.log(page, 'page')},},})然后在第三頁里面監聽current的值
<div class="swiper-wrap"><div class="swiper-container"><div class="swiper-wrapper"><divclass="swiper-slide"v-for="(item, index) of swiperData":key="`three_${index}`"><a :href="item.url"><img :src="item.imgSrc" alt="" /></a></div></div><div class="swiper-pagination"></div></div> export default {props: {current: {type: Number,default: 1,},},watch: {current: {handler(new, old) { //翻到了第三頁if (new === 3) {this.initSwiper()}},immediate: true,},},methods: {initSwiper() {new Swiper('.swiper-container', {autoplay: {delay: 2000,stopOnLastSlide: false,disableOnInteraction: false,},loop: true,keyboard: true,mousewheel: true,on: {click: function() {alert('click')},},pagination: {el: '.swiper-pagination',},})}} }總結
以上是生活随笔為你收集整理的swiper 在turn.js不能滚动的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 鼠标经过图片抖动效果
- 下一篇: lol好听的名字829个