coolair
V2EX  ›  微信

请问下 dayjs 怎么在微信小程序的 wxml 页面里面使用?

  •  
  •   coolair · Jul 13, 2022 · 1575 views
    This topic created in 1403 days ago, the information mentioned may be changed or developed.
    现在是在 js 里面转好,有没有办法直接在 wxml 里面使用?
    7 replies    2022-07-25 16:59:29 +08:00
    zcf0508
        1
    zcf0508  
       Jul 13, 2022
    在 methods 里把 dayjs 相关的方法暴露出去就可以了
    magewu1223ll
        2
    magewu1223ll  
       Jul 13, 2022
    把包下下来 放进你的项目里
    coolair
        3
    coolair  
    OP
       Jul 13, 2022
    @zcf0508 老哥,怎么操作的,直接在 js 里面暴露然后再 wxml 里面调用?

    <tag value="{{ dayjs(mydatetime).format('YYYY-MM-DD HH:mm:ss') }}" />

    像上面这样写,没有效果啊。
    zcf0508
        4
    zcf0508  
       Jul 13, 2022
    methods:{
    dayjsformat(datetime,format):{
    return dayjs(datetime).format(format)
    }
    }
    coolair
        5
    coolair  
    OP
       Jul 13, 2022
    @zcf0508 老哥,没有用啊,用法是我上面写的那样吗?
    zcf0508
        6
    zcf0508  
       Jul 13, 2022
    @coolair <tag :value="{{ dayjsformat(mydatetime,'YYYY-MM-DD HH:mm:ss') }}" />
    coolair
        7
    coolair  
    OP
       Jul 25, 2022
    @zcf0508 老哥,测试了没用啊,原生小程序不能这么写吧,你这是 Vue 的写法吧?
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   3066 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 39ms · UTC 04:06 · PVG 12:06 · LAX 21:06 · JFK 00:06
    ♥ Do have faith in what you're doing.