我正在尝试使用 angular 指令实现水平 iScroll。
这是我的指令代码。
link: function(scope, elem, attrs) {
scope.winWidth = window.innerWidth;
scope.iScrollWidth = scope.winWidth *8.5 +'px';
jQuery(angular.element(attrs.thelist)).css({'width':scope.iScrollWidth});
var k_videoScroll = new iScroll(angular.element(attrs.scrollwrap),{
snap: true,
bounce: false,
checkDOMChanges: false,
momentum: false,
hScrollbar: false,
vScrollbar: false,
overflow: false
});
我的 html 页面中有一个 div 标记,其 id 与 attrs.scrollwrap 相关
<div id="videolist" class="videoScrollWrap" options="#thelist" wrapper="#deal-wrap" scrollwrap="#videoReviewsWrap">
<div id="videoReviewsWrap">
<ul id="thelist">
<li id='deal-wrap' ng-repeat="video in videoList" videoList='video'></li>
</ul>
</div>
</div>
我遇到的问题是'无法设置未定义的属性'溢出''。
TypeError: Cannot set property 'overflow' of undefined
at Object.iScroll (http://localhost/swordfish/web/js/lib/iscroll.js:89:31)
at setScroll (http://localhost/swordfish/web/js/directives/d-product-details.js:395:33)
at link (http://localhost/swordfish/web/js/directives/d-product-details.js:405:13)
at o (http://localhost/swordfish/web/js/lib/angular/angular.min.js:42:187)
at e (http://localhost/swordfish/web/js/lib/angular/angular.min.js:38:28)
at http://localhost/swordfish/web/js/lib/angular/angular.min.js:37:118
at <error: illegal access>
at Object.e.$broadcast (http://localhost/swordfish/web/js/lib/angular/angular.min.js:88:517)
at http://localhost/swordfish/web/js/lib/angular/angular.min.js:81:85
at i (http://localhost/swordfish/web/js/lib/angular/angular.min.js:76:207) <div id="videolist" class="videoScrollWrap ng-isolate-scope ng-scope" options="#thelist" wrapper="#deal-wrap" scrollwrap="#videoReviewsWrap"> angular.min.js:60
(匿名函数)
可能是什么问题?似乎定义新 iScroll 的语法不正确。这样做的正确方法是什么?
提前致谢!