我正在Yeoman Angular生成的文件夾上工作。我通過Bower安裝了一個需要jQuery的模塊。咕嚕的wiredep放置在index.html
的AngularJS上述jQuery的依賴關係,如下所示:jQuery依賴上面Angular one:警告:試圖加載角度不止一次
<!-- build:js(.) scripts/vendor.js -->
<!-- bower:js -->
<script src="bower_components/jquery/dist/jquery.js"></script>
<script src="bower_components/angular/angular.js"></script>
<script src="bower_components/angular-animate/angular-animate.js"></script>
...
<!-- endbower -->
<!-- endbuild -->
這似乎是合理的,因爲jQuery的不依賴於角。
的事情是,當我嘗試加載我的應用程序在瀏覽器中,我得到了JS控制檯以下消息:
Synchronous XMLHttpRequest on the main thread is deprecated because of its detrimental effects to the end user's experience. For more help, check http://xhr.spec.whatwg.org/.
VM80711:26293
WARNING: Tried to load angular more than once.
angular-animate.js:442 Uncaught TypeError: Cannot read property 'offsetWidth' of null
如果我手動進行交換index.html
的jQuery
依賴與angular
之一,一切像魅力一樣工作,但當我的應用程序grunt build
設置了默認順序時,所以我無法獲得dist文件夾中的工作配置。
bower.json
:
{
"name": "webapp",
"version": "0.1.0",
"dependencies": {
"angular": "^1.3.0",
"angular-animate": "^1.3.0",
"angular-resource": "^1.3.0",
"angular-sanitize": "^1.3.0",
"angular-touch": "^1.3.0",
"angular-ui-router": "~0.2.14",
"angular-material": "~0.9.0",
"restangular": "~1.5.1",
"angular-slick": "~0.2.1",
"ngInfiniteScroll": "~1.2.1"
},
"devDependencies": {
"angular-mocks": "^1.3.0"
},
"appPath": "app",
"moduleName": "app"
}
非常感謝您的幫助在這裏!
感謝,S hehryar!問題是' 事'。我仍然想知道爲什麼在依賴項導入切換時發生這種情況。 –
Alvaro