第一步:npm安装dayjs
npm i dayjs
第二步导入:
import * as moment from 'dayjs'
import relativeTime from 'dayjs/plugin/relativeTime'
import 'dayjs/locale/zh-cn'
moment.extend(relativeTime)
moment.locale('zh-cn')
第三步使用
moment(time).fromNow()
第一步:npm安装dayjs
npm i dayjs
第二步导入:
import * as moment from 'dayjs'
import relativeTime from 'dayjs/plugin/relativeTime'
import 'dayjs/locale/zh-cn'
moment.extend(relativeTime)
moment.locale('zh-cn')
第三步使用
moment(time).fromNow()