警告:试图装入不止一次角多。当我的JQuery包括 [英] WARNING: Tried to load angular more than once. when I include JQuery

查看:148
本文介绍了警告:试图装入不止一次角多。当我的JQuery包括的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我建立一个自耕农与应用的角度发电机。

I am building an yeoman app with an angular-generator.

包含在我的index.html文件库中的JS是:

The js libraries included in my index.html file are:

<script src="bower_components/jquery/dist/jquery.js"></script>
<script src="bower_components/modernizr/modernizr.js"></script>
<script src="bower_components/angular/angular.js"></script>   
<script src="bower_components/angular-ui-router/release/angular-ui-router.js"></script>
<script src="bower_components/d3/d3.js"></script>
<script src="bower_components/select2/select2.js"></script>
<script src="bower_components/angular-ui-select2/src/select2.js"></script>

如果jQuery是包含之前的角度,如果是后它不会只发生时出现问题。

The problem only occurs if jquery is included before angular and it does not happen if it is after it.

作为标题美国的问题是,我得到的警告:试图装入不止一次角多的控制台和应用程序无法初始化

The problem as the title states is that I get "WARNING: Tried to load angular more than once" in the console and the app cannot initialize.

有没有人有任何线索,为什么会发生这种情况?

Does anyone have any clues why this can happen?

我有一个单一的NG-应用程序,我包括角只有一次...一切。它看起来并不像它关系到配置的东西,因为改变脚本的位置修复它。

I have a single ng-app, I am including angular just once... and everything. It does not look like it is something related to the configuration because changing the position of the script fixes it.

你们是否有任何线索?

有谁知道我是否能够配置到包括脚本的顺序?由于我采用了棱角分明发电机我跟usemin将此设为包括凉亭脚本。我不知道是否有什么办法可以指定其中以包括脚本。

Does anyone know if I am able to configure to include order of the scripts? As I am using angular-generator I have set this up with usemin to include the bower scripts. I wonder if there is any way to be able to specify in which order to include the scripts.

这是我的项目bower.json文件:

This is the bower.json file for my project:

{
  "name": "<name>",
  "version": "0.0.0",
  "dependencies": {
    "angular": "1.2.15",
    "json3": "~3.2.6",
    "es5-shim": "~2.1.0",
    "angular-ui-router": "~0.2.10",
    "modernizr": "~2.8.1",
    "d3": "~3.4.6",
    "angular-ui-select2": "~0.0.5"
  },
  "devDependencies": {
    "angular-mocks": "1.2.15",
    "angular-scenario": "1.2.15"
  }
}

我曾尝试在谷歌没有运气搜索。
在此先感谢!

I have tried to search in google with no luck. Thanks in advance!

更新1:

我刚刚发现,如果我有脚本这样,角将不会被包含两次,它总是先加载。

I just found out that if I include the scripts this way, angular won't be included twice and it is always loaded first.

  <!-- build:js scripts/vendor.js -->
  <script src="bower_components/angular/angular.js"></script>
  <!-- bower:js -->
  <script src="bower_components/jquery/dist/jquery.js"></script>
  <script src="bower_components/modernizr/modernizr.js"></script>
  <script src="bower_components/angular-ui-router/release/angular-ui-router.js"></script>
  <script src="bower_components/d3/d3.js"></script>
  <script src="bower_components/select2/select2.js"></script>
  <script src="bower_components/angular-ui-select2/src/select2.js"></script>
  <!-- endbower -->

不是最好的解决办法,但至少现在......不管怎么说,我想有亭子里面的一切:JS代码

Not the best solution but at least for now... Anyways, I would like to have everything inside bower:js tags.

推荐答案

长时间的测试后...它结束了,关于我的index.html文件我有一个

After long hours of testing... it ended up being that on my index.html file I had a

<ui-view />

由角UI路由器使用,它取代这一点,并获得成功。

to be used by angular ui router and replacing it to this, did the trick.

<ui-view></ui-view>

这篇关于警告:试图装入不止一次角多。当我的JQuery包括的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆