可以用moment库
import moment from 'moment';
moment(Date.now()).format('YYYY-MM-DD HH:mm:ss')
获取格式化的时间
/**
* 组织下载文件名称
* @param {*} title
*/
const getFileName = title => {
const now = new Date();
const timeStr = `${now.getFullYear()}${now.getMonth() +
1}${now.getDate()}${now.getHours()}${now.getMinutes()}${
now.getSeconds() < 10 ? `0${now.getSeconds()}` : now.getSeconds()
}${now.getMilliseconds()}`;
return `${title}-${timeStr}`;
};