我正在使用 SwiperJS (www.swiperjs.com),我遇到了滑动到下一张照片的问题,但上一个和下一个按钮没有。我已经查看了我可以在这里找到的每一篇文章以及遵循他们的文档,但仍然没有任何运气。
<div id="openModal" class="modalDialog" style="display: none;">
<div class="modal-content">
<a href="#close" title="Close" class="close" onclick="$('#openModal').hide()">X</a>
<h2>Modal Box</h2>
<p>Hello world</p>
<script src="https://unpkg.com/swiper/js/swiper.min.js"></script>
<link rel="stylesheet" href="https://unpkg.com/swiper/css/swiper.css">
<link rel="stylesheet" href="https://unpkg.com/swiper/css/swiper.min.css">
<!-- Slider main container -->
<div class="swiper-container">
<!-- Additional required wrapper -->
<div id="swiper" class="swiper-wrapper">
<!-- Slides -->
<div class="swiper-slide"><img src="http://<server>/path/to/image.png"></div>
<div class="swiper-slide"><img src="http://<server>/path/to/image2.png"></div>
</div>
<!-- If we need pagination -->
<div class="swiper-pagination"></div>
<!-- If we need navigation buttons -->
<div class="swiper-button-prev"></div>
<div class="swiper-button-next"></div>
<!-- If we need scrollbar -->
<div class="swiper-scrollbar"></div>
</div>
<script>
var mySwiper = new Swiper ('.swiper-container', {
// Optional parameters
direction: 'horizontal',
loop: true,
centeredSlides: true,
slidesPerView: 1,
pagination: '.swiper-pagination',
paginationClickable: '.swiper-pagination',
nextButton: '.swiper-button-next',
prevButton: '.swiper-button-prev',
})
</script>
为了初始化 Swiper JS,我也从他们的网站上尝试过:
<script>
var mySwiper = new Swiper ('.swiper-container', {
// Optional parameters
direction: 'vertical',
loop: true,
// If we need pagination
pagination: {
el: '.swiper-pagination',
},
// Navigation arrows
navigation: {
nextEl: '.swiper-button-next',
prevEl: '.swiper-button-prev',
},
// And if we need scrollbar
scrollbar: {
el: '.swiper-scrollbar',
},
})
</script>
有人对我可以尝试什么有任何想法吗?我还发现分页按钮没有像他们的示例那样显示在底部,但与上一个和下一个按钮不起作用相比,这不是一个问题。就像我说的,如果我单击并拖动或“滑动”,它会很好地移动到下一张幻灯片,所以我假设它与 JS 部分有关,但不确定要尝试什么。