我想补充iScroll的两个实例在一个页面上但我不认为是这个原因:iScroll - 属性未定义的错误
function loaded() {
$('.iScrolls').each(function(){
var $this = $(this);
var $id = $this.attr('id');
if($id) {
$scrollers[$id] = new iScroll($id, {
snap: true,
momentum: false,
hScrollbar: false,
onScrollEnd: function() {
$('#indicator > li.active').removeAttr('class');
$('#indicator > li:nth-child(' + (this.currPageX + 1) + ')').removeAttr('class').addClass('active');
}
});
$('.prev', $this).click(function(){
$scrollers[$id].scrollToPage('prev', 0);
return false;
});
$('.next', $this).click(function(){
$scrollers[$id].scrollToPage('next', 0);
return false;
});
}
});
}
document.addEventListener('DOMContentLoaded', loaded, false);
当“scrollToPage被触发我得到的错误:
Uncaught TypeError: Cannot read property 'length' of undefined
iScroll.scrollTo iScroll.js:984
iScroll._end iScroll.js:614
iScroll.handleEvent
我的问题的存在有没有人碰到这个来知道是什么原因造成的?
关于