解析
Day.js 没有修改原生 Date.prototype
,而是为 Date
对象创建了一个封装器。要获取此封装器对象,只需使用一种受支持的输入类型调用 dayjs()
。
¥Instead of modifying the native Date.prototype
, Day.js creates a wrapper for the Date
object. To get this wrapper object, simply call dayjs()
with one of the supported input types.
Day.js 对象是不可变的,也就是说,以某种方式更改 Day.js 对象的所有 API 操作都将返回它的新实例。
¥The Day.js object is immutable, that is, all API operations that change the Day.js object in some way will return a new instance of it.