工作中使用到的 js 函数!
- 格式化时间:
formatDatetime(time='', str='datetime')
npm i dodo-js-lib --save
import * as jslib from 'dodo-js-lib'
console.log(jslib.formatDatetime(), formatDatetime())
formatDatetime 函数
alert(lib.formatDatetime('Fri Nov 25 2022 14:54:58 GMT+0800 (中国标准时间)')) // new Date().toString()
alert(lib.formatDatetime('2022-11-25 12:12:12')) // format
alert(lib.formatDatetime('2022-11-25T06:52:17.041Z')) // new Date().toJSON()
alert(lib.formatDatetime(1669359195535)) // new Date().getTime()
rewirteLog 函数
重写console方法,在生产环境中不显示调试log
在main.js中
import {rewirteLog} from './lib/utils'
rewirteLog()