在我用 Typescript 编写的 Ionic 2 项目中,我使用 moment.js 库。
我使用代码片段导入它:
import * as moment from 'moment';
这样做之后,在我的组件中我可以正常使用 moment,即:
let endDate = moment(data.endDate);
但是,现在我想使用此存储库中专用于 moment.js 的插件之一 - moment-weekday-calc :https://github.com/andruhon/moment-weekday-calc https://github.com/andruhon/moment-weekday-calc
我已经通过 npm 安装了插件,但无法使其运行。
我试过了:
import * as moment from 'moment';
import 'moment-weekday-calc';
//(...) - 我的组件代码在这里
let test = moment().isoWeekdayCalc({
rangeStart: '1 Apr 2015',
rangeEnd: '31 Mar 2016',
weekdays: [1,2,3,4,5],
exclusions: ['6 Apr 2015','7 Apr 2015'],
inclusions: ['10 Apr 2015']
}); //260
上面的代码抛出一个错误:
Typescript Error
Property 'isoWeekdayCalc' does not exist on type 'Moment'.
知道如何在我的 ionic/cordova 打字稿应用程序中使用这个插件吗?