首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Swiper.js - Uncaught :无法读取属性'params‘的null

Swiper.js - Uncaught :无法读取属性'params‘的null
EN

Stack Overflow用户
提问于 2016-01-06 04:52:36
回答 1查看 11.1K关注 0票数 1

我使用的是swiper.js并一旦使用了swper1.def();运行、重新构建、滑到某个幻灯片并单击。

我得到了swiper.js:438 Uncaught的错误:无法读取空的属性'params‘

这是密码。我很感激所有的帮助。非常感谢。

代码语言:javascript
复制
$('.call').click(function(e){
e.preventDefault()

$("#menu").addClass("hide");
$("#slider").removeClass("hide");

selector.push("address");

var swiper1 = new Swiper('.swiper1', {
    pagination: '.one',
    paginationClickable: true,
    hashnav: true,
    loop:true,
    initialSlide:0
});

getLocation();

$('.noclick').click(function(e){
    e.preventDefault()
    swiper1.unlockSwipes(); // <-- This seems to be causing the problem
    swiper1.slidePrev(); // <-- This seems to be causing the problem
    player.seekTo(0);
})

$('.yes').click(function(e){
    e.preventDefault()
    swiper1.unlockSwipes(); // <-- This seems to be causing the problem
    swiper1.slideNext(); // <-- This seems to be causing the problem
})

$('.overlay').click(function(e){
    swiper1.unlockSwipes();
    console.log("overlay");
    e.preventDefault()
    $("#menu").removeClass("hide");
    $("#slider").addClass("hide");
    swiper1.destroy();
})

swiper1.on('slideChangeStart', function () {
    var dataindex = $(".swiper-slide-active").data('index');
    console.log(dataindex);

    if(dataindex == 8){
        onPlayerReady();
        swiper1.lockSwipes();
        setTimeout(function(){
            //var state = player.getPlayerState();
            //console.log(state);
            //if (state == 0){
                //alert("This should work");
                swiper1.unlockSwipes();
                swiper1.slideTo(9);
            //}
        },4000);

    }else if(dataindex == 9) {  
        swiper1.lockSwipes();
    }else if(dataindex == 10){
        swiper1.lockSwipes();
    }else{
        stopVideo();
    }
});

})
EN

回答 1

Stack Overflow用户

发布于 2017-12-01 14:49:47

我遇到了类似的错误,我需要正确地删除swiper.destroy()上的旧事件侦听器,并附加新的事件侦听器,因为以前的事件侦听器是指被破坏的对象。

在我的例子中,它看起来像这样

代码语言:javascript
复制
// on init
window.addEventListener('keydown', this.handleKeypressFn)

..
// than somewhere before destroy()
window.removeEventListener('keydown', this.handleKeypressFn)
swiper1.destroy()
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/34625845

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档