![](/img/trans.png)
[英]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.