/**
* 获取随机数
* @param {*} min number 最小值
* @param {*} max number 最大值
* @returns number
*/exportconstgetRandomNum=(min =0, max =100)=>{return Math.floor(Math.random()*(max - min))+ min
}
日期格式化
/**
* 日期格式化
* @param {*} date date 日期 new Date()
* @param {*} fmt string 日期格式 'yyyy-MM-dd hh:mm:ss'
* @returns string
*/exportconst formatDate =(date =newDate(), fmt ='yyyy-MM-dd hh:mm:ss')=>{if(/(y+)/.test(fmt)){
fmt = fmt.replace(
RegExp.$1,`${date.getFullYear()}`.substr(4- RegExp.$1.length))}let o ={'M+': date.getMonth()+1,'d+': date.getDate(),'h+': date.getHours(),'m+': date.getMinutes(),'s+': date.getSeconds(),}// 遍历这个对象for(let k in o){if(newRegExp(`(${k})`).test(fmt)){let str =`${o[k]}`
fmt = fmt.replace(
RegExp.$1,
RegExp.$1.length ===1? str :padLeftZero(str))}}return fmt
}