【发布时间】:2015-11-26 12:19:11
【问题描述】:
我的项目设置包括用于库的“jspm”工具和用于打字的“tsd”工具。
安装 moment 的 TypeScript d.ts 文件 (these) 后,我找不到加载和实际使用 moment 实例的方法。
在我的文件中(使用 SystemJS 模块加载)
/// <reference path="../../../typings/tsd.d.ts" />
import * as moment from "moment";
import * as _ from "lodash";
...
...
const now = (this.timestamp === 0) ? moment() : moment(this.timestamp);
我收到“TypeError: moment is not a function”
定义的结构与lodash相同,效果很好,所以我不知道可能是什么原因。
谁能帮忙?
【问题讨论】:
-
你试过
import { moment } from 'moment'吗?如果找不到较新版本的 d.ts,尝试使用 moment 2.8.0 也可能很有用。 -
@wilenx 真有趣,我刚刚在大约 10 分钟前为这个问题添加了赏金stackoverflow.com/questions/32987273/…
标签: typescript momentjs systemjs