【发布时间】:2014-09-23 03:27:11
【问题描述】:
所以 - 我想在 ember 应用程序中使用 typeahead。
我启动并运行了一个 cli 应用程序,然后我运行
bower install typeahead.js
我可以看到代码已经放入 bower_components。
然后我将以下内容添加到 brocfile:
/* global require, module */
var EmberApp = require('ember-cli/lib/broccoli/ember-app');
var app = new EmberApp();
// Use `app.import` to add additional libraries to the generated
// output files.
//
// If you need to use different assets in different
// environments, specify an object as the first parameter. That
// object's keys should be the environment name and the values
// should be the asset to use in that environment.
//
// If the library that you are including contains AMD or ES6
// modules that you would like to import into your application
// please specify an object with the list of modules as keys
// along with the exports of each module as its value.
app.import('bower_components/typeahead.js/dist/typeahead.bundle.min.js');
module.exports = app.toTree();
但是它不起作用 - 我明白了
Uncaught ReferenceError: Bloodhound is not defined
通过阅读文档 - 使用 bower 安装并在 brocfile 中添加行应该足以满足它吗?是我读错了还是这是一个错误?
我创建了一个显示此问题的公共 GIT 存储库:
https://github.com/wayne-o/ember-cli-bootstrap
我所做的只是:
ember new bootstrap-test
bower install bootstrap
然后添加:
app.import('bower_components/bootstrap/dist/css/bootstrap.css');
app.import('bower_components/bootstrap/dist/js/bootstrap.js');
到 brockfile...
没用……
【问题讨论】:
-
typeahead.bundle.min.js 应该包含寻血猎犬。尝试删除 Bloodhound.js 导入
-
仍然收到错误:/
-
@drorb 我已经修改了问题并在 github 上添加了一个显示问题的 repo...
-
更新了我的答案@iwayneo