本地化要支持中文的
vueuse 的 useTimeAgo 可惜不支持中文呀
![]() |
1
weixind 249 天前
谜底不就在谜面上么。
|
![]() |
2
davin 249 天前 ![]() 官方 issue 底下有结合 i18n 的不错的解决方案 /issues/1592
|
![]() |
3
raphaelsoul 249 天前
date-fns/formatDistance
如有需要处理成月/年的自己除 30/365 就好 差个一两天没人在意的 |
![]() |
4
dfkjgklfdjg 249 天前
[Intl.RelativeTimeFormat - JavaScript | MDN]( https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/RelativeTimeFormat)
|
![]() |
5
bojackhorseman 249 天前 via iPhone
dayjs 好像也支持吧
|
![]() |
6
butanediol2d 249 天前
不了解前端,不过应该都有 icu 的 port 吧
|
7
fjc0k 249 天前
跳出 Vue ,它只是个 ui 框架
|
![]() |
8
NoManPlay 249 天前
需要现成 hooks 就上面说的 useTimeAgo+i18n
|
![]() |
9
NoManPlay 249 天前
@NoManPlay 不局限可以考虑 dayjs. https://day.js.org/docs/zh-CN/display/from-now
|
10
laters 249 天前
dayjs
|
![]() |
11
snowlee 249 天前
|
![]() |
12
dfkjgklfdjg 249 天前
@dfkjgklfdjg #4 ,补充一下,useTimeAge 支持传入格式化文本的。
格式看这里 👉 [vueuse/packages/core/useTimeAgo/index.ts at main · vueuse/vueuse]( https://github.com/vueuse/vueuse/blob/main/packages/core/useTimeAgo/index.ts#L92) |
13
thawne 249 天前
dayjs
|
![]() |
14
66beta 249 天前
`dayjs.updateLocale`
|
![]() |
16
magicdawn 248 天前 via Android
|