Authored by ccbikai

sale 页面单张swiper不初始化

@@ -16,10 +16,13 @@ var index = 0, @@ -16,10 +16,13 @@ var index = 0,
16 page = 0, 16 page = 0,
17 pd = ""; 17 pd = "";
18 18
19 -swiper = new Swiper('.swiper-container', {  
20 - lazyLoading: true,  
21 - pagination: '.swiper-pagination'  
22 -}); 19 +// slide 个数大于 1 时,使用 swiper ,否则只显示单张图片
  20 +if ($('.swiper-container .swiper-slide').length > 1) {
  21 + swiper = new Swiper('.swiper-container', {
  22 + lazyLoading: true,
  23 + pagination: '.swiper-pagination'
  24 + });
  25 +}
23 26
24 lazyLoad($('img.lazy')); 27 lazyLoad($('img.lazy'));
25 $curNav = $navList.children('.focus'); 28 $curNav = $navList.children('.focus');
@@ -18,7 +18,7 @@ var winH = $(window).height(), @@ -18,7 +18,7 @@ var winH = $(window).height(),
18 var swiper; 18 var swiper;
19 19
20 // slide 个数大于 1 时,使用 swiper ,否则只显示单张图片 20 // slide 个数大于 1 时,使用 swiper ,否则只显示单张图片
21 -if ($('.swiper-container').length > 1) { 21 +if ($('.swiper-container .swiper-slide').length > 1) {
22 swiper = new Swiper('.swiper-container', { 22 swiper = new Swiper('.swiper-container', {
23 lazyLoading: true, 23 lazyLoading: true,
24 pagination: '.swiper-pagination' 24 pagination: '.swiper-pagination'