试图围绕Ember.js包裹我的头。 似乎我理解复杂的事情,但错过了小事情。ember.js包含自定义js
如何添加一个example.js文件? 为简单起见,假设该example.js文件只包含:
(function(){
console.log("example is alive in console");
})(window);
这应该显示“的例子是在控制台活着”浏览器控制台中。
我曾尝试: 加入余烬-CLI-build.js内app.import('vendor/javascripts/example.js');
和添加<script src="{{rootURL}}vendor/javascripts/example.js"></script>
到的index.html
控制台表示
ⓧ GET http://localhost:4200/vendor/javascripts/example.js
DEBUG:---- ---------------------------
DEBUG:Ember:2.11.3
DEBUG:Ember数据:2.12.1
DEBUG:jQuery的:3.2.1
DEBUG:-------------------------------
ⓧ GET http://localhost:4200/vendor/javascripts/example.js
我发现的所有答案都表明,只需将custom.js添加到供应商文件即可。可悲的是,我错过了一些东西。
感谢您的验证。我将文件切换到根目录,同样的问题。然后将其放回/javascripts/example.js,并从index.html中移除''并重新启动ember服务器。看,知道这是愚蠢的。修改ember-cli-build.js时,你必须手动重新启动ember服务器。 livereload服务器不会接受更改。 – William