bootstrap-table 使用 requirejs 进行本地化会出错 "Cannot read property 'locales' of undefined"

bootstrap-table localization with requirejs gives error "Cannot read property 'locales' of undefined"

将 TYPO3 用作 CMS,我尝试使用 requirejs 加载 bootstrap-table 本地化版本,但出现此错误: Uncaught TypeError: Cannot read property 'locales' of undefined.

首先,如果我只加载 bootstrap-table.min.js 一切正常:

define([
    'jquery',
    'TYPO3/CMS/Iancalendar/bootstrap-table.min'
], function($, bootstrapTable) {

但是我在添加本地化文件时遇到了这个错误:

define([
    'jquery',
    'TYPO3/CMS/Iancalendar/bootstrap-table.min',
    'TYPO3/CMS/Iancalendar/bootstrap-table-locale-all.min'
], function($, bootstrapTable, btl) {

错误发生在 bootstrap-table-locale-all.min.js 的这一行:

t.fn.bootstrapTable.locales["af-ZA"]

所以我想那是因为 t.fn.bootstrapTable 还没有在那里定义。

拜托,有什么办法可以帮助我解决这个问题吗?

使用 PageRenderer 的 addRequireJsConfiguration 方法和此代码解决 ext_localconf.php

\TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Core\Page\PageRenderer::class)->addRequireJsConfiguration([
    'shim' => [
        'bootstrapTable' => ['jquery'],
        'bootstrapTableLocale' => ['jquery', 'bootstrapTable'],
    ],
    'paths' => [
        'bootstrapTable' => \TYPO3\CMS\Core\Utility\PathUtility::getAbsoluteWebPath(
                \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath('iancalendar', 'Resources/Public/JavaScript/Contrib/')
            ) . 'bootstrap-table.min',
        'bootstrapTableLocale' => \TYPO3\CMS\Core\Utility\PathUtility::getAbsoluteWebPath(
                \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath('iancalendar', 'Resources/Public/JavaScript/Contrib/')
            ) . 'bootstrap-table-locale-all.min',
    ]
]);

这样我就可以像这样在Main.js中加载模块

define([
    'jquery',
    'bootstrapTable',
    'bootstrapTableLocale'
], function($, bootstrapTable, bootstrapTableLocale) {
...