我正在尝试将力矩范围包导入我的 Angular 4.x 应用程序,官方文档显示了这一点:-
import Moment from 'moment';
import { extendMoment } from 'moment-range';
const moment = extendMoment(Moment);
但是在我的应用程序时刻已通过以下方法添加:
import * as Moment from 'moment';
所以我决定使用相同的方法来尝试让矩范围起作用
import * as Moment from 'moment';
import * as MomentRange from 'moment-range';
const moment = MomentRange(Moment);
但是我收到以下打字稿错误 - 任何人都可以建议我如何解决这个问题吗?
Cannot invoke an expression whose type lacks a call signature.
Type 'typeof "/node_modules/moment-range/dist/moment-range"'
has no compatible call signatures.
在 github 上找到了这个,它对我有用 - 希望它能帮助其他人
import * as moment from 'moment';
import { extendMoment } from 'moment-range';
const { range } = extendMoment(moment);
const timeRange = range(moment.utc([2015, 0, 1]), moment.utc([2015, 5, 1]));