我是一个Angular-RequireJs项目。
我面临的问题是,在IE 11中,滚动条没有出现,我收到错误
TypeError:对象不支持属性或方法 ' perfectScrollbar'
无法获得财产'致电'未定义或空引用
在Chrome浏览器中,我有时会发现滚动条运行顺畅且没有错误。但有时我收到错误
TypeError:$ elem.perfectScrollbar不是函数 在angular-perfect-scrollbar.js:26 at m。$ digest(angular.min.js:146) at m。$ apply(angular.min.js:149) 在l(angular.min.js:102)
未捕获的TypeError:无法读取属性' call'未定义的 在ig(angular.min.js:39) 在HTMLDivElement.d(angular.min.js:39)
如果我包括
<script src="assets/libs/js/jquery-3.1.0.min.js" ></script>
<script src="bower_components/perfect-scrollbar/min/perfect-scrollbar.with-mousewheel.min.js"></script>
直接进入index.html文件,一切正常。
有人可以帮助我解决此问题。
require配置文件具有以下代码。
require.config({
waitSeconds: 40,
baseUrl: '/demo/',
paths: {
"angular" : "assets/libs/js/angular.min",
"angular-route" : "assets/libs/js/angular-ui-router",
"angular-sanitize" : "assets/libs/js/angular-sanitize",
"bootstrap": "assets/libs/js/bootstrap",
"angular-translate": "assets/libs/js/angular-translate/angular-translate",
"angular-translate-loader": "assets/libs/js/angular-translate-loader/angular-translate-loader-partial",
"ui.bootstrap": "assets/libs/js/ui-bootstrap-tpls-1.3.3.min",
"jquery": "assets/libs/js/jquery-3.1.0.min",
"bootstrap-datepicker": "assets/libs/js/datepicker/bootstrap-datepicker",
"moment": "assets/libs/js/moment",
"filesaver":"assets/libs/js/FileSaver.min",
"ui.select":"assets/libs/js/select",
"CryptoJS":"assets/libs/js/aes",
"angular-idle":"assets/libs/js/angular-idle",
"perfect-scrollbar":"bower_components/perfect-scrollbar/min/perfect-scrollbar.with-mousewheel.min",
"angular-perfect-scrollbar":"src/angular-perfect-scrollbar",
"app": "config/app",
"core": "core"
},
shim : {
"ui.bootstrap" : ["angular"],
"angular-route" : ["angular"],
"angular-sanitize" : ["angular"],
"angular-translate" : ["angular"],
"angular-translate-loader": ["angular","angular-translate"],
"bootstrap-datepicker": ["angular","ui.bootstrap"],
"ui.select":["angular"],
"angular-idle":["angular"],
"angular-perfect-scrollbar":["jquery","perfect-scrollbar","angular"]
},
packages : ["core"],
deps : ["app"]
});
app.js文件的结构如下,
define(['require',
'angular',
'angular-route',
'angular-sanitize',
'angular-translate',
'angular-translate-loader',
'ui.bootstrap',
'ui.select',
'modules/master/main',
'config/routes',
'CryptoJS',
'angular-idle','angular-perfect-scrollbar'], function (require) {
var app = angular.module('JJAR', ['ngSanitize', 'ui.router', 'pascalprecht.translate', 'ui.bootstrap', 'ui.select', 'JJAR.master', 'ngIdle', 'perfect_scrollbar']);
app.config(function ($stateProvider, $urlRouterProvider, $translateProvider, $translatePartialLoaderProvider, CONSTANTS, $locationProvider, KeepaliveProvider, IdleProvider) {
在html中,完美滚动条指令的用法如下:
<div perfect-scrollbar wheel-propagation="true" suppress-scroll-X="true" wheel-speed="40" max-scrollbar-length="30" min-scrollbar-length="30" class="scroller col-md-12">