1)获取当前时间戳
txStartTime:this.getCurrentDate(),
methods: {
getCurrentDate() {
const now = new Date();
const year = now.getFullYear();
const month = (now.getMonth() + 1).toString().padStart(2, '0');
const day = now.getDate().toString().padStart(2, '0');
const hours = this.padNumber(now.getHours());
const minutes = this.padNumber(now.getMinutes());
const seconds = this.padNumber(now.getSeconds());
const milliseconds = now.getMilliseconds();
return year+month+day+hours+minutes+seconds+milliseconds;
},
}
输出
txStartTime
:
"20240724201643276"
2)转字符串
a+""
3)生成随机数
random100000() {
return Math.floor(Math.random() * 100000) + 1;
},