Swiper.js-未捕获类型错误:无法读取属性'params'为null
Swiper.js - Uncaught TypeError: Cannot read property 'params' of null
我使用的是swiper.js和一次swiper1.destroy();运行、重建、滑动到某个幻灯片并单击。
我得到swipper.js:438 Uncaught TypeError:无法读取null的属性"params"的错误
这是代码。我感谢所有的帮助。非常感谢。
$('.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();
}
});
})
我得到了类似的错误,我需要正确地删除swiper.destroy()
上的旧事件侦听器并附加新的侦听器,因为以前的侦听器是指已销毁的对象。
在我的情况下,它看起来像这个
// on init
window.addEventListener('keydown', this.handleKeypressFn)
..
// than somewhere before destroy()
window.removeEventListener('keydown', this.handleKeypressFn)
swiper1.destroy()
相关文章:
- TypeError:无法读取属性'推'未定义的JavaScript
- 同样,同样的错误'ahorcado.js:26未捕获类型错误:无法读取属性'beginPath'
- 未捕获的TypeError无法读取未定义的属性socialsharing
- 未捕获的类型错误:无法读取属性'删除'的未定义
- AngularJS指令出错-无法读取属性'编译'的未定义
- 未捕获的类型错误:无法读取属性'name'即使它存在,也无法定义
- 看到“;未捕获的类型错误:无法读取属性'weight'未定义的“;尽管按照字面上的指示
- angularjs无法读取未定义的属性then
- 无法读取属性'材料'未定义的Three.js
- 得到"TypeError:无法读取属性'filename'未定义的“;调用“npm start
- Soundcloud api"未捕获的类型错误:无法读取属性'uri'“未定义”;
- 未捕获的类型错误:无法读取属性'addEventListener'的null chrome扩展名
- Soundcloud Javascript SDK 3.0-回调无法读取属性'connectCallback
- 未捕获的类型错误:无法读取属性'状态'在react中为null
- JavaScript承诺-无法读取属性'那么'的未定义
- Javascript Float32数组抛出无法读取属性'0'即使数组定义良好,也为null
- 未捕获的类型错误:无法读取属性'中止'的未定义
- 角度推入数组给出:TypeError:无法读取属性'推'的未定义
- http/rxjs catch回调中的Angular 2重定向导致TypeError:无法读取属性'订阅'
- 角度输入模型有条件地从一个属性读取,写入另一个属性