coolair
V2EX  ›  问与答

有朋友在小程序上用过 moment.js 和 dayjs 之类的库吗?

  •  
  •   coolair · Aug 28, 2019 · 3942 views
    This topic created in 2475 days ago, the information mentioned may be changed or developed.

    我用 moment.js ,在本地,和开发调试模式(手机扫码)没有问题,在体验模式下报错: <TypeError: s is not a function>

    用 dayjs,其中用到了 dayjs-plugin-utc.min.js 插件,但是在 extend 的时候报错: Uncaught TypeError: t is not a function

    有朋友知道怎么解决吗?谢谢

    使用代码如下:

    const moment = require('../../utils/moment-with-locales.min.js')
    
    const  dayjs = require('../../utils/dayjs.min.js')
    const dayjsPluginUTC = require('../../utils/dayjs-plugin-utc.min.js')
    dayjs.extend()
    
    1 replies    2019-09-02 16:00:22 +08:00
    iamkun
        1
    iamkun  
       Sep 2, 2019
    小程序 require 有个 default 所以正确的写法是
    ```
    dayjs.extend(dayjsPluginUTC.default)
    ```
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   3160 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 44ms · UTC 14:03 · PVG 22:03 · LAX 07:03 · JFK 10:03
    ♥ Do have faith in what you're doing.