在新增请求的时候需要向后端传输类似“2024-09-23”的实时时间格式
模板:
方法:
//改时间数据格式
this.timeNow = new Date();
const formattedDate =`${this.timeNow.getFullYear()}-${this.padZero(this.timeNow.getMonth() + 1)}-${this.padZero(this.timeNow.getDate())} ${this.padZero(this.timeNow.getHours())}:${this.padZero(this.timeNow.getMinutes())}:${this.padZero(this.timeNow.getSeconds())}`;
Date()似乎还得转一下格式
//时间格式转换
padZero(num) {
return num < 10 ? `0${num}` : num;
},
整体:
控制台: