0

我有以下代码用于动态加载语言环境

declare var System;
let angularLocale = convertAbpLocaleToAngularLocale(abp.localization.currentLanguage.name);
        System.import(`@angular/common/locales/${angularLocale}.js`)
            .then(module => {
                registerLocaleData(module.default);
                NgxBootstrapDatePickerConfigService.registerNgxBootstrapDatePickerLocales().then(_ => {
                    resolve(true);
                    abp.ui.clearBusy();
                });
            }, reject);

如果我不使用系统,则构建命令会引发异常

Module not found: Error: Package path ./locales is not exported from package ....\node_modules\@angular\common (see exports field in .....\node_modules\@angular\common\package.json)

如果我使用系统,我会在浏览器控制台中遇到异常

core.mjs:6495 
        
       ERROR Error: Uncaught (in promise): ReferenceError: System is not defined
ReferenceError: System is not defined
    at registerLocales (root.module.ts:193)
    at root.module.ts:64
    at ZoneDelegate.invoke (zone.js:400)
    at Object.onInvoke (core.mjs:25877)
    at ZoneDelegate.invoke (zone.js:399)
    at Zone.run (zone.js:160)
    at zone.js:1318
    at ZoneDelegate.invokeTask (zone.js:434)
    at Object.onInvokeTask (core.mjs:25864)
    at ZoneDelegate.invokeTask (zone.js:433)
    at resolvePromise (zone.js:1255)
    at zone.js:1325
    at ZoneDelegate.invokeTask (zone.js:434)
    at Object.onInvokeTask (core.mjs:25864)
    at ZoneDelegate.invokeTask (zone.js:433)
    at Zone.runTask (zone.js:205)
    at drainMicroTaskQueue (zone.js:620)
4

1 回答 1

0

我对“找不到模块”有同样的问题。在应用程序中,我们使用 i18n。现在我从 i18n 获取国家,然后将语言环境设置为管道,女巫持有此信息。所以我不再需要动态模块加载。也许这对你有帮助?

于 2021-11-23T12:43:12.203 回答