【发布时间】:2023-04-04 23:04:01
【问题描述】:
我正在尝试进行一些代码拆分,而 moment.js 是我想在单独的块中隔离的目标包之一。我是这样做的:
const myFn = async (currentNb) => {
const moment = (await import('moment')).default()
const dateUnix: number = moment(currentNb).valueOf()
[...]
}
但我收到以下错误:this expression is not callable. Type Moment has no call signatures。所以我想我应该做类似moment.valueOf(currentNb) 的事情,但我不太确定。有人可以对此有所了解吗?提前致谢
【问题讨论】:
-
我不确定
moment的正确类型是什么,但它看起来像是Function.. 值得一试.. 另请查看stackoverflow.com/questions/29689966/…
标签: javascript reactjs momentjs code-splitting