vue3+vite项目
安装moment
yarn add moment
在要使用moment的页面引入moment
import moment from 'moment'
import 'moment/dist/locale/zh-cn'
*注意是dist下的locale
moment.locale('zh-cn')
moment("2023-07-22").fromNow()
更多moment的使用看Moment.js 中文网 | 开发文档
vue3+vite项目
安装moment
yarn add moment
在要使用moment的页面引入moment
import moment from 'moment'
import 'moment/dist/locale/zh-cn'
*注意是dist下的locale
moment.locale('zh-cn')
moment("2023-07-22").fromNow()
更多moment的使用看Moment.js 中文网 | 开发文档