全局地更改语言环境
默认情况下,Day.js 仅提供英语语言环境。
¥By default, Day.js comes with English locale only.
如果你需要其他语言环境,可以按需加载。
¥If you need other locales, you can load them on demand.
require('dayjs/locale/de')
加载语言环境后,它就会成为活动语言环境。要更改活动区域设置,只需使用已加载区域设置的键调用 dayjs.locale
即可更改全局区域设置。
¥Once you load a locale, it becomes the active locale. To change active locales, simply call dayjs.locale
with the key of a loaded locale to change global locale.
更改全局区域设置不会影响现有实例。
¥Changing the global locale doesn't affect existing instances.
dayjs.locale('de') // use loaded locale globally
dayjs.locale('en') // switch back to default English locale globally