1.安装day.js
npm install dayjs --save
2.点击小程序工具,Npm构造器
![在这里插入图片描述](https://img-blog.csdnimg.cn/5420d2f8800747e4b607f546cf85e64b.png#pic_center)
![在这里插入图片描述](https://img-blog.csdnimg.cn/f0d6b9ef01c1469182cade381352de30.png#pic_center)
注意此操作会删除miniprogram_npm下的文件夹,操作之前应该备份,然后复制到此文件夹下面才不会影响原来的代码
3.页面使用
JS 中引入
var dayjs = require('dayjs')
代码使用
var today = dayjs().format('YYYY-MM-DD HH:mm:ss')
参考链接
- https://www.cnblogs.com/chenwolong/p/15594635.html
- https://dayjs.fenxianglu.cn/category/#浏览器
- https://blog.csdn.net/weixin_43862596/article/details/121247282