1. const suijishu = this.getProjectNum() + Math.floor(Math.random() * 1000) //需要几位随机数就写几个0
2. getProjectNum() {
const projectTime = new Date() // 当前中国标准时间
const Year = projectTime.getFullYear() // 获取当前年份 支持IE和火狐浏览器.
const Month = projectTime.getMonth() + 1 // 获取中国区月份
const Day = projectTime.getDate() // 获取几号
let CurrentDate = Year
if (Month >= 10) { // 判断月份和几号是否大于10或者小于10
CurrentDate += Month
} else {
CurrentDate += `0${Month}`
}
if (Day >= 10) {
CurrentDate += Day
} else {
CurrentDate += `0${Day}`
}
return CurrentDate
},
随机生成-日期加随机数
于 2022-09-21 15:35:20 首次发布