• 请不要在回答技术问题时复制粘贴 AI 生成的内容
imherer
V2EX  ›  程序员

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

  •  
  •   imherer · Jun 14, 2024 · 3265 views
    This topic created in 872 days ago, the information mentioned may be changed or developed.

    本地化要支持中文的

    vueuse 的 useTimeAgo 可惜不支持中文呀

    16 replies  •  2024-06-15 12:30:39 +08:00
    weixind
    weixind
    Jun 14, 2024
    1
    谜底不就在谜面上么。
    davin
    davin
    Jun 14, 2024❤️1
    2
    官方 issue 底下有结合 i18n 的不错的解决方案 /issues/1592
    0x4b0082
    0x4b0082
    Jun 14, 2024
    3
    date-fns/formatDistance

    如有需要处理成月/年的自己除 30/365 就好 差个一两天没人在意的
    dumbass
    dumbass
    Jun 14, 2024 via iPhone
    5
    dayjs 好像也支持吧
    butanediol2d
    butanediol2d
    Jun 14, 2024
    6
    不了解前端,不过应该都有 icu 的 port 吧
    fjc0k
    fjc0k
    Jun 14, 2024
    7
    跳出 Vue ,它只是个 ui 框架
    NoManPlay
    NoManPlay
    Jun 14, 2024
    8
    需要现成 hooks 就上面说的 useTimeAgo+i18n
    NoManPlay
    NoManPlay
    Jun 14, 2024
    9
    laters
    laters
    Jun 14, 2024
    10
    dayjs
    94
    94
    Jun 14, 2024
    12
    @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
    thawne
    Jun 14, 2024
    13
    dayjs
    66beta
    66beta
    Jun 14, 2024
    14
    `dayjs.updateLocale`
    66beta
    66beta
    Jun 14, 2024
    15
    @66beta #14 dayjs.updateLocale -> relativeTime
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   5501 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 65ms · UTC 02:27 · PVG 10:27 · LAX 18:27 · JFK 21:27
    ♥ Do have faith in what you're doing.