V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
imherer
V2EX  ›  程序员

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

  •  
  •   imherer · 4 天前 · 1366 次点击

    本地化要支持中文的

    vueuse 的 useTimeAgo 可惜不支持中文呀

    16 条回复    2024-06-15 12:30:39 +08:00
    weixind
        1
    weixind  
       4 天前
    谜底不就在谜面上么。
    davin
        2
    davin  
       4 天前   ❤️ 1
    官方 issue 底下有结合 i18n 的不错的解决方案 /issues/1592
    raphaelsoul
        3
    raphaelsoul  
       4 天前
    date-fns/formatDistance

    如有需要处理成月/年的自己除 30/365 就好 差个一两天没人在意的
    bojackhorseman
        5
    bojackhorseman  
       4 天前 via iPhone
    dayjs 好像也支持吧
    butanediol2d
        6
    butanediol2d  
       4 天前
    不了解前端,不过应该都有 icu 的 port 吧
    fjc0k
        7
    fjc0k  
       4 天前
    跳出 Vue ,它只是个 ui 框架
    NoManPlay
        8
    NoManPlay  
       4 天前
    需要现成 hooks 就上面说的 useTimeAgo+i18n
    NoManPlay
        9
    NoManPlay  
       4 天前
    laters
        10
    laters  
       4 天前
    dayjs
    snowlee
        11
    snowlee  
       4 天前
    dfkjgklfdjg
        12
    dfkjgklfdjg  
       4 天前
    @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
    thawne  
       4 天前
    dayjs
    66beta
        14
    66beta  
       4 天前
    `dayjs.updateLocale`
    66beta
        15
    66beta  
       4 天前
    @66beta #14 dayjs.updateLocale -> relativeTime
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   2953 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 23ms · UTC 12:22 · PVG 20:22 · LAX 05:22 · JFK 08:22
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.