[英]Importing moment-timzone and moment-range with webpack (Babel/ES6)
[英]Importing moment-range into Angular 4.x application (ES6) - no compatible call signatures error?
我正在尝试将矩程包导入到我的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]));
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.