访问我的ember网站的主页时,该页面未加载并在控制台中显示此错误:
Error: Could not find module jquery ember.js:251
TypeError: Ember.DataAdapter is undefined ember-data.js:4529
TypeError: Ember.Handlebars is undefined compiled-templates.js:1
TypeError: Ember.Route is undefined combined-scripts.js:19
ReferenceError: jQuery is not defined affix.js:126
ReferenceError: jQuery is not defined alert.js:98
ReferenceError: jQuery is not defined dropdown.js:154
ReferenceError: jQuery is not defined tooltip.js:386
ReferenceError: jQuery is not defined modal.js:246
ReferenceError: jQuery is not defined transition.js:56
ReferenceError: jQuery is not defined button.js:109
ReferenceError: jQuery is not defined popover.js:117
ReferenceError: jQuery is not defined carousel.js:217
ReferenceError: jQuery is not defined scrollspy.js:158
ReferenceError: jQuery is not defined collapse.js:179
ReferenceError: jQuery is not defined tab.js:135
"DEBUG: For more advanced debugging, install the Ember Inspector from https://addons.mozilla.org/en-US/firefox/addon/ember-inspector/" ember.js:3521
我用yeoman生成了一个ember项目。我的一个更改(我不确定哪一个,可能是css更改)导致此错误突然发生。
我已经使用bower list
检查了依赖关系,如下所示,并且可以确认jQuery在那里:
myapp#0.0.0 /usr/local/src/myapp
├─┬ bootstrap-sass#3.0.2
│ └── jquery#2.1.0 (2.1.1-beta1 available)
├─┬ ember#1.5.0 (latest is 1.6.0-beta.2)
│ ├── handlebars#1.2.1 (1.3.0 available, latest is 2.0.0-alpha.2)
│ └── jquery#2.1.0 (latest is 2.1.1-beta1)
├─┬ ember-data#1.0.0-beta.7
│ └─┬ ember#1.5.0 (1.6.0-beta.2 available)
│ ├── handlebars#1.2.1
│ └── jquery#2.1.0
├── ember-mocha-adapter#0.1.2 (latest is 0.2.0)
├── handlebars#1.2.1 (latest is 2.0.0-alpha.2)
├── holderjs#2.3.2
└── jquery#2.1.0 (2.1.1-beta1 available)
我是javascript开发的新手,并希望了解可能存在的问题。
更新:
构建期间发生的一项艰巨任务是将index.html文件从我的源文件夹(到.tmp)复制,并用对正确依赖项的引用替换它的内容:
Found a block:
<!-- build:js(app) scripts/components.js -->
<script src="bower_components/jquery/jquery.js"></script>
<script src="bower_components/handlebars/handlebars.runtime.js"></script>
<script src="bower_components/ember/ember.prod.js"></script>
<script src="bower_components/ember-data/ember-data.prod.js"></script>
<!-- endbuild -->
Updating config with the following assets:
- app/bower_components/jquery/jquery.js
- app/bower_components/handlebars/handlebars.runtime.js
- app/bower_components/ember/ember.prod.js
- app/bower_components/ember-data/ember-data.prod.js
此处显示已加载给定资产,包括jquery。 Jquery是2.1.0,而ember是1.5.0。
答案 0 :(得分:2)
答案是由于自上一版本以来jquery依赖项中发生的更改,jquery.js文件现在位于bower安装的dist文件夹下。
即。
<script src="bower_components/dist/jquery/jquery.js"></script>
我已将我的更改提交为拉取请求ember yeoman generator on github(已经合并)