如何在aurelia中使用已安装的模块

时间:2016-04-20 07:54:49

标签: aurelia

我正在使用skeleton-typescript示例并完成文档。我正在尝试使用数字设置一个数值转换器,如docs中所示。

import numeral from 'numeral';

export class CurrencyFormatValueConverter {
  toView(value) {
    return numeral(value).format('($0,0.00)');
  }
}

我已经通过jspm install numeral安装了数字。它在jspm依赖项中添加了package.json,我手动将它添加到bundles.js。

保存typescript文件后,我收到错误:Cannot find module 'numeral'.。我错过了什么?

2 个答案:

答案 0 :(得分:3)

你需要数字为数字.js。由于打字没有d.ts,这可以解决问题:

$ jspm install npm:@types/numeral.

它可以在我的骨架中使用值转换器。导入可以像import * as numeral from 'numeral';

那样完成

答案 1 :(得分:0)

您应该在配置中添加它,如:

export function configure(aurelia) {
    aurelia.use
        .standardConfiguration()
        .developmentLogging()
        .plugin('numeral'); 

    aurelia.start().then(() => aurelia.setRoot());
}

您将在package.json中找到确切的包名:

jspm": {
   "dependencies": {
        ...
        "numeral": "xxxx"
        ...
    }
}