//时间戳转时间 function formatDate(time, flag) { const t = new Date(time); const tf = function(i){return (i < 10 ? '0' : '') + i}; const year = t.getFullYear(); const month = tf(t.getMonth() + 1); const day = tf(t.getDate()); const hour = tf(t.getHours()); const minute = tf(t.getMinutes()); const seconds = tf(t.getSeconds()); const map = new Map([ [1, month + '月' + day + '日' + ' ' + hour + ':' + minute], [2, year + '-' + month + '-' + day], [3, month + '-' + day + ' ' + hour + ':' + minute], [4, year + '年' + month + '月' + day + '日'], [5, day.toString().substring(1,2)], [6, month + '.' + day], [7, year + '年' + month + '月' + day + '日' + hour + '时' + minute + '分' + seconds + '秒'] ]) return map.has(flag) && map.get(flag) } export default formatDate