【问题标题】:FullCalendar Angular 13 error when importing npm library导入 npm 库时出现 FullCalendar Angular 13 错误
【发布时间】:2022-12-19 18:03:56
【问题描述】:

我有一个导入 Angular FullCalendar v5 的 npm 库,一切正常。当我尝试将我的项目库导入另一个项目并尝试访问完整的日历前端时,我在浏览器控制台中收到警告和消息错误:

 - Warning: main.js:7358 Unknown option 'default'
 - Error: core.mjs:6476 ERROR TypeError: Language ID should be string or object.
    at new DateTimeFormat (<anonymous>)
    at buildNativeFormattingFunc (main.js:1218)
    at NativeFormatter.buildFormattingFunc (main.js:1211)
    at NativeFormatter.buildFormattingFunc (main.js:1009)
    at NativeFormatter.format (main.js:1154)
    at NativeFormatter.formatRange (main.js:1169)
    at DateEnv.formatRange (main.js:3984)
    at CalendarDataManager.buildTitle (main.js:6909)
    at CalendarDataManager.buildTitle (main.js:1009)
    at CalendarDataManager.updateData (main.js:7113)

我不明白为什么,但我知道它在 main.js (@fullcalendar/common/main.js) 的这一行代码中 Line 1218 -> var normalFormat = new Intl.DateTimeFormat(context.locale.codes, standardDateProps); 错误是变量context.locale.codes未定义。

谁能帮忙?

【问题讨论】:

    标签: npm fullcalendar angular13


    【解决方案1】:

    这是一个老问题,但它可能仍然相关,我希望我的回答可以帮助任何为此苦苦挣扎的人。 我刚刚遇到了同样的错误。不是我导入了我自己的项目库,而是导入了 Fullcalendar 库(来自 node_modules)。我使用日历选项的 locale 属性启用了本地化,但我总是收到此错误 Language ID should be string or object

    有两件事是错误的:

    1. 我错误地导入了语言环境代码,导致了这个错误。 Fullcalendar (6.0.0) 的当前版本的所有区域设置代码都在@fullcalendar/core/locales 下。

    2. 我正在使用这样的动态导入:import("@fullcalendar/core/locales/da") 并且它工作正常但我必须访问导出对象的 default 属性。使用 async/await 语法,它变成:

      const localeModule = await import("@fullcalendar/core/locales/da");

      const calendar = new Calendar(someElement, { (...),
      语言环境:localeModule.default

      });

      没有直接回答您的问题,但听起来您也在使用区域设置,并且您的其他项目正在导入您的项目库,使得包含区域设置代码的模块的 default 属性未定义。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2019-01-12
      • 2023-03-29
      • 1970-01-01
      • 1970-01-01
      • 2022-10-24
      • 2015-09-01
      • 2018-12-05
      相关资源
      最近更新 更多