2
我將項目切換到模塊。所以大多數情況都在起作用,但一些組件有一些問題。主要問題似乎本地化文件。 如果我有這個例子的解決方案,我可以解決我的項目中的其他問題。RequireJS + Bootstrap日期選擇器+語言環境文件
我使用的是引導日期選擇器從這裏https://bootstrap-datepicker.readthedocs.org/
Requirejs配置:
require.config({
baseUrl: "Scripts",
paths: {
... some more like jquery and jquery-ui...
"bootstrap-datepicker": "bootstrap-datepicker",
"bootstrap-datepicker-de": "./locales/bootstrap-datepicker.de",
}
shim: {
'bootstrap-datepicker-de': ['bootstrap-datepicker']
}
});
App.ts:
... some more imports like jquery and jquery-ui...
import "bootstrap-datepicker";
import "bootstrap-datepicker-de";
... init App ...
引導-datepicker.de.js
; (function ($) {
$.fn.datepicker.dates['de'] = {
days: ["Sonntag", "Montag", "Dienstag", "Mittwoch", "Donnerstag", "Freitag", "Samstag"],
daysShort: ["Son", "Mon", "Die", "Mit", "Don", "Fre", "Sam"],
daysMin: ["So", "Mo", "Di", "Mi", "Do", "Fr", "Sa"],
months: ["Januar", "Februar", "März", "April", "Mai", "Juni", "Juli", "August", "September", "Oktober", "November", "Dezember"],
monthsShort: ["Jan", "Feb", "Mär", "Apr", "Mai", "Jun", "Jul", "Aug", "Sep", "Okt", "Nov", "Dez"],
today: "Heute",
monthsTitle: "Monate",
clear: "Löschen",
weekStart: 1,
format: "dd.mm.yyyy"
};
}(jQuery));
當我打開我的網頁我得到這個錯誤:
bootstrap-datepicker.de.js:7 Uncaught TypeError: Cannot set property 'de' of undefined
at bootstrap-datepicker.de.js:7
at bootstrap-datepicker.de.js:19
沒有一個很好的解決方案的構造方法解決了這個問題,但似乎唯一的工作解決方案 –