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

标签 aurelia

我正在使用 sculpture-typescript 示例并阅读文档。我正在尝试设置一个带有数字的值转换器,如 docs 中所示。 .

import numeral from 'numeral';

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

我已经通过 jspm install numeric 安装了 numeric。它被添加到 jspm 依赖项中的 package.json 中,并且我手动将其添加到 bundles.js 中。

保存 typescript 文件后,出现错误:找不到模块“numeral”。。我错过了什么?

最佳答案

您需要为 numeric.js 提供 d.ts。由于打字上没有 d.ts,这可以解决问题:

$ jspm install npm:@types/numeral.

它在我的骨架中与值转换器一起工作。导入可以像 import * as numeric from 'numeral';

一样完成

关于aurelia - 如何使用 aurelia 中已安装的模块,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36737301/

相关文章:

javascript - Aurelia EventAggregator 未正确导入

ecmascript-6 - Babel 转译 es7 类装饰器出现意外的标记错误

ecmascript-6 - 用于导出类函数的 es6 访问器

javascript - aurelia-fetch-client.d.ts undefined symbol

knockout.js - 使用条件逻辑编写 HTML View

Aurelia 通过自定义元素将字符串绑定(bind)到模板

javascript - 使用 aureliajs 和 babel-polyfill 时 IE11 中出现堆栈空间不足错误

node.js - Aurelia bundle 和 jspm 配置文件

typescript - 带有 Aurelia 和 typescript 的 dhtmlxscheduler

javascript - 加载 aurelia-validation 插件时出错