Swiper中文论坛
标题:
swiper销毁报错
[打印本页]
作者:
dingxiaoming
时间:
2018-10-12 18:36
标题:
swiper销毁报错
本帖最后由 dingxiaoming 于 2018-10-12 18:37 编辑
使用的时swiper4,在销毁的时候报错:
Uncaught TypeError: Page.mySwiper.a11y.destory is not a function
下面时我的代码:
$(".J_swiper").click(function(){
var _this = $(this);
var _src = _this.attr("src");
var _index = _this.index();
var group = _this.attr("group");
var img = new Image();
img.src = _src;
var clientWidth = document.documentElement.clientWidth;
var clientHeight = document.documentElement.clientHeight;
$(".show-inner").css({
width:img.width,
height:img.height,
marginTop:(clientHeight - img.height)/2
});
$(".J_swiper[group="+group+"]").each(function(index,item){
var div = document.createElement("div");
$(".show-img").append($(div).addClass("swiper-slide").append($(item).clone()));
});
$(".show-pictures-container").show();
setTimeout(function(){
Page.mySwiper = new Swiper('.swiper-container',{
initialSlide :_index || 0,
slidesPerView : 1,
pagination: {
el: '.swiper-pagination',
},
});
},0);
});
$(".mask").click(function(){
console.log(Page.mySwiper);
Page.mySwiper.destory(true,true);
$(".show-pictures-container").hide();
$(".show-inner .show-img").empty();
});
复制代码
欢迎光临 Swiper中文论坛 (http://bbs.swiper.com.cn/)
Powered by Discuz! X3.2