时间格式化
formatDate(date) {
const year = date.getFullYear();
const month = String(date.getMonth() + 1).padStart(2, "0");
const day = String(date.getDate()).padStart(2, "0");
const hours = String(date.getHours()).padStart(2, "0");
const minutes = String(date.getMinutes()).padStart(2, "0");
const seconds = String(date.getSeconds()).padStart(2, "0");
return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
// 格式 2023-08-29 10:24:00
},
数字分割
const total = '0000000000'
// 数字分割和逗号添加
const formatted = total
.toString()
.replace(/\B(?=(\d{3})+(?!\d))/g, ',')
// console.log(formatted) 0,000,000,000
this.captionDataSum = formatted.split('')