查看: 2939|回复: 1
打印 上一主题 下一主题

swiper销毁报错

[复制链接]

该用户从未签到

1

主题

1

帖子

4

积分

新手上路

Rank: 1

积分
4
跳转到指定楼层
楼主
发表于 2018-10-12 18:36:01 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
本帖最后由 dingxiaoming 于 2018-10-12 18:37 编辑

使用的时swiper4,在销毁的时候报错:Uncaught TypeError: Page.mySwiper.a11y.destory is not a function下面时我的代码:

  1. $(".J_swiper").click(function(){
  2.   var _this = $(this);
  3.   var _src = _this.attr("src");
  4.   var _index = _this.index();
  5.   var group = _this.attr("group");
  6.   var img =  new Image();
  7.   img.src = _src;
  8.   var clientWidth = document.documentElement.clientWidth;
  9.   var clientHeight = document.documentElement.clientHeight;
  10.   $(".show-inner").css({
  11.     width:img.width,
  12.     height:img.height,
  13.     marginTop:(clientHeight - img.height)/2
  14.   });
  15.   $(".J_swiper[group="+group+"]").each(function(index,item){
  16.     var div = document.createElement("div");
  17.     $(".show-img").append($(div).addClass("swiper-slide").append($(item).clone()));
  18.   });
  19.   $(".show-pictures-container").show();
  20.   setTimeout(function(){
  21.     Page.mySwiper = new Swiper('.swiper-container',{
  22.       initialSlide :_index || 0,
  23.       slidesPerView : 1,
  24.       pagination: {
  25.         el: '.swiper-pagination',
  26.       },
  27.     });
  28.   },0);
  29. });
  30. $(".mask").click(function(){
  31.   console.log(Page.mySwiper);
  32.   Page.mySwiper.destory(true,true);
  33.   $(".show-pictures-container").hide();
  34.   $(".show-inner .show-img").empty();
  35. });
复制代码



分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享分享 分享淘帖
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|小黑屋|Swiper中文网 ( 粤ICP备15001020号

GMT+8, 2024-5-6 15:49 , Processed in 0.121349 second(s), 30 queries .

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表