ember.js - 使用供应商目录

ember.js - use of vendor directory

当我尝试引用 vendor 中的资产时,我得到了 404 - 有人会告诉我我做错了什么吗?

为了跟进 doco(https://guides.emberjs.com/v2.13.0/addons-and-dependencies/managing-dependencies/ 标题为 'Other Assets' 的段落),我复制了一些 js/css 到 vendor 目录。

在 index.html 我添加了 :

<script src="vendor/gmaps.js"></script>

当我然后 运行 ember s 页面呈现时,但对 vendor return 404.

中的资产的引用

我也试过了:

 <script src="{{rootURL}}vendor/gmaps.js"></script>

同样的结果。

我做错了什么?

在构建 Ember 应用程序时,我从未找到向 index.html 文件添加 <script><link> 或任何标签的好用例.放置在适当 vendor 文件夹中的任何内容都可以通过添加...

injected/concatenated/compiled 到 vendor.js 文件中
app.import('vendor/your_vendor_folder/your_vendor_file.js');

...到您的 ember-cli-build.js 文件。在 "Other Assets" 文档之后,在 "Compiling Assets" section.

中进一步详细说明了此编译过程

When you're using dependencies that are not included in an addon, you will have to instruct Ember CLI to include your assets in the build. This is done using the asset manifest file ember-cli-build.js. You should only try to import assets located in the bower_components and vendor folders.

这样做会将该文件注册为全局文件,可以在您的任何 Ember 对象中使用。请记住,您可能需要编辑 .jshintrc 以删除任何 JSHint 错误。