我正在尝试迁移 ember 应用程序以使用ember app-kit。该代码需要accounting.js 库。在 pre-app-kit 版本中,文件是通过脚本标签加载的index.html
<script src="http://cdnjs.cloudflare.com/ajax/libs/accounting.js/0.3.2/accounting.min.js"></script>
并通过全局命名空间在视图中访问
App.MoneyField= Em.TextField.extend({
init: function() {
this._super();
var value = accounting.formatMoney(this.get("money") / 100, '');
this.set('value', value);
};
// other functions omitted
});
在 app-kit 版本中,我将accounting.js
其作为 bower 依赖项包含在内。在bower.json
:
{
"name": "ember-app-kit",
"dependencies": {
"handlebars": "~1.1.2",
"jquery": "~1.9.1",
"qunit": "~1.12.0",
"ember": "~1.4.0-beta.2",
"ember-data": "~1.0.0-beta.6",
"ember-resolver": "git://github.com/stefanpenner/ember-jj-abrams-resolver.git#master",
"ic-ajax": "~0.3.0",
"ember-testing-httpRespond": "~0.1.1",
"accounting":"~0.3.2"
},
"resolutions": {
"ember": "~1.4.0-beta.2"
}
}
当我尝试构建应用程序时,它给出了错误
W117: 'accounting' is not defined.
我理解为什么会这样,并且知道我需要某种import accounting from ...
声明。
如何将通过 bower 安装的包作为 ES6 模块导入?