时间:2021-07-01 10:21:17 帮助过:35人阅读
<div class="swiper-container"> <div class="swiper-wrapper"> <div class="swiper-slide">H5EDU1</div> <div class="swiper-slide">H5EDU2</div> <div class="swiper-slide">H5EDU3</div> <div class="swiper-slide">H5EDU4</div> <div class="swiper-slide">H5EDU5</div> </div> <div class="swiper-pagination"></div> <div class="swiper-button-next"></div> <div class="swiper-button-prev"></div> </div>
然后在js当中进行初始化并且设定CSS样式。
var swiper = new Swiper('.swiper-container',{ pagination:'.swiper-pagination', slidesPerView:1, paginationClickable:true, spaceBetween:30, nextButton:'.swiper-button-next', prevButton:'.swiper-button-prev', keyboardControl:true //开启键盘控制翻页 });
如上我们只是在初始化当中添加了
keyboardControl:true就可以让swiper页面有键盘控制翻页的效果。如果不添加是不可以用键盘控制页面滚动的
以上就是swiper的基础使用(十九)的内容,更多相关内容请关注PHP中文网(www.gxlcms.com)!