var Pager; $(function () { Pager = { methods: function () { return { init: function init() { Pager.events.init(); } }; }(), events: function () { return { init: function init() { //swiper banner图初始化 var bannerCount = $(".swiper-slide").length; var mySwiper = null; if (bannerCount <= 1) { $(".pagination").hide(); } else { mySwiper = new Swiper('.swiperBannerContainer', { autoplay: 6000, //可选选项,自动滑动 loop: true, //可选选项,开启循环 pagination: '.pagination', paginationClickable: true, onInit: function onInit(swiper) { //swiper.swipeNext() } }); } $('.swiperBannerContainer').hover(function () { if (bannerCount > 1) { $('.prev').show(); $('.next').show(); } }, function () { $('.prev').hide(); $('.next').hide(); }); $('.prev').click(function () { mySwiper.swipePrev(); }); $('.next').click(function () { mySwiper.swipeNext(); }); }, }; }(), }; Pager.methods.init(); });