|
本帖最后由 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();
- });
复制代码
|
|