获取语言配置的属性
你可以通过调用 dayjs.localeData()
来获得当前全局语言配置的属性,或dayjs().localeData()
获取当前 Day.js 对象的。
这依赖 LocaleData 插件,才能正常运行
javascript
dayjs.extend(localeData);
globalLocaleData = dayjs.localeData();
globalLocaleData.firstDayOfWeek();
globalLocaleData.months();
globalLocaleData.monthsShort();
globalLocaleData.weekdays();
globalLocaleData.weekdaysShort();
globalLocaleData.weekdaysMin();
globalLocaleData.months(dayjs());
globalLocaleData.monthsShort(dayjs());
globalLocaleData.weekdays(dayjs());
globalLocaleData.weekdaysShort(dayjs());
globalLocaleData.weekdaysMin(dayjs());
instanceLocaleData = dayjs().localeData();
instanceLocaleData.firstDayOfWeek();
instanceLocaleData.months();
instanceLocaleData.monthsShort();
instanceLocaleData.weekdays();
instanceLocaleData.weekdaysShort();
instanceLocaleData.weekdaysMin();