gpt4 book ai didi

javascript - iDangerous 滑动不起作用

转载 作者:行者123 更新时间:2023-11-30 17:05:52 24 4
gpt4 key购买 nike

我一直在尝试在我的刷卡器上放置一个下一个/上一个按钮,但我无法让它工作我已经尝试了各种方法,但它就是不起作用,有人可以解释为什么它不起作用。我使用的是 jquery 而不是 zepto。

试过这个。

<span class="button-next">Next button</span>
<span class="button-prev">Previous button</span>
<script>
$(function(){
var mySwiper = $('.swiper-container').swiper();
$('.button-next').click(function(){mySwiper.swipeNext()})
$('.button-prev').click(function(){mySwiper.swipePrev()})

})
</script>

这就是我初始化滑动的方式,效果很好。

var swiper1 = new Swiper('.swiper-container.newscol-swiper',{ 
slideClass: 'post-item',
slidesPerView: 4,
slidesPerViewFit: false,
loop: true,
centeredSlides: true,
autoplay: 5000,
speed: 400,
calculateHeight: true,
roundLength: true,
mode: 'horizontal'
})

最佳答案

您是否尝试过使用以下方法? (确保你使用的是最新版本的 Swiper)

var swiper = new Swiper('.swiper-container', {
pagination: '.swiper-pagination',
paginationClickable: '.swiper-pagination',
nextButton: '.swiper-button-next',
prevButton: '.swiper-button-prev',
spaceBetween: 30
});
html,
body {
position: relative;
height: 100%;
}
body {
background: #eee;
font-family: Helvetica Neue, Helvetica, Arial, sans-serif;
font-size: 14px;
color: #000;
margin: 0;
padding: 0;
}
.swiper-container {
width: 100%;
height: 100%;
}
.swiper-slide {
text-align: center;
font-size: 18px;
background: #fff;
/* Center slide text vertically */
display: -webkit-box;
display: -ms-flexbox;
display: -webkit-flex;
display: flex;
-webkit-box-pack: center;
-ms-flex-pack: center;
-webkit-justify-content: center;
justify-content: center;
-webkit-box-align: center;
-ms-flex-align: center;
-webkit-align-items: center;
align-items: center;
}
<link href="https://rawgit.com/nolimits4web/Swiper/master/dist/css/swiper.min.css" rel="stylesheet" />
<script src="https://rawgit.com/nolimits4web/Swiper/master/dist/js/swiper.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<div class="swiper-container">
<div class="swiper-wrapper">
<div class="swiper-slide">Slide 1</div>
<div class="swiper-slide">Slide 2</div>
<div class="swiper-slide">Slide 3</div>
<div class="swiper-slide">Slide 4</div>
<div class="swiper-slide">Slide 5</div>
<div class="swiper-slide">Slide 6</div>
<div class="swiper-slide">Slide 7</div>
<div class="swiper-slide">Slide 8</div>
<div class="swiper-slide">Slide 9</div>
<div class="swiper-slide">Slide 10</div>
</div>
<!-- Add Pagination -->
<div class="swiper-pagination"></div>
<!-- Add Arrows -->
<div class="swiper-button-next"></div>
<div class="swiper-button-prev"></div>
</div>

按照此处的说明: https://github.com/nolimits4web/Swiper/blob/master/demos/14-nav-arrows.html

关于javascript - iDangerous 滑动不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28046893/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com