在ts中使用dayjs

分为两种情况:

  1. 没有在tsconfig.json中进行如下配置
"compilerOptions": {
        "esModuleInterop": true,
        "allowSyntheticDefaultImports": true,
    }

在使用dayjs的页面中通过如下进行导入

important * as dayjs from 'dayjs';
  1. 如果进行了配置,则需要通过如下方式导入
important dayjs from 'dayjs';

版权声明:本文为weixin_42937036原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。