导入 MomentJS 导致以下错误:
ERROR in [...] Cannot invoke an expression whose type lacks a call signature. Type 'typeof moment' has no compatible call signatures.
如何解决此错误?
最佳答案
最新版本的 MomentJS 现在已经定义了类型。重新安装 MomentJS,无需外部类型。您还应该避免命名空间样式导入,因为无法调用或构造此类导入,并且会导致运行时失败。
要走的路是传统导入:
从“时刻”导入时刻;
关于javascript - 如何在 Typescript 中正确导入 MomentJS 解决以下错误 : "Type ' typeof moment' has no compatible call signatures.》,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55131138/