最近用iscroll.js 写移动页面,效果仍是挺好的。但,仍是会遇到从新初始化的问题。html
var myScroll = new IScroll('#rule_wrapper',{
click:true
});app
myScroll.refresh();spa
吐槽一下,没用没用啊~htm
好吧,查看了些帖子,最后的解决办法,增长定时,为啥呢?Js是有任务栈的。blog
方法1:使用myScroll.refresh();get
setTimeout(function(){
myScroll.refresh();
},1500)io
方法2:使用 checkDOMChanges: truefunction
$scope.loaded = function () { $timeout(function () { $scope.schoolId = new IScroll('#schoolId', { scrollX: false, scrollY: true, mouseWheel: true, checkDOMChanges: true }); $scope.courseId = new IScroll('#courseId', { scrollX: false, scrollY: true, mouseWheel: true, checkDOMChanges: true }); $scope.gradeId = new IScroll('#gradeId', { scrollX: false, scrollY: true, mouseWheel: true, checkDOMChanges: true }); },1500) }