前端大佬们有没有好用的 timeago 库

13 天前
 imherer

本地化要支持中文的

vueuse 的 useTimeAgo 可惜不支持中文呀

1469 次点击
所在节点    程序员
16 条回复
weixind
13 天前
谜底不就在谜面上么。
davin
13 天前
官方 issue 底下有结合 i18n 的不错的解决方案 /issues/1592
raphaelsoul
13 天前
date-fns/formatDistance

如有需要处理成月/年的自己除 30/365 就好 差个一两天没人在意的
dfkjgklfdjg
13 天前
bojackhorseman
13 天前
dayjs 好像也支持吧
butanediol2d
13 天前
不了解前端,不过应该都有 icu 的 port 吧
fjc0k
13 天前
跳出 Vue ,它只是个 ui 框架
NoManPlay
13 天前
需要现成 hooks 就上面说的 useTimeAgo+i18n
NoManPlay
13 天前
laters
13 天前
dayjs
snowlee
13 天前
dfkjgklfdjg
13 天前
@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)
thawne
13 天前
dayjs
66beta
13 天前
`dayjs.updateLocale`
66beta
13 天前
@66beta #14 dayjs.updateLocale -> relativeTime
magicdawn
12 天前

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/1049476

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX