数据库返回的数据格式:2020-10-19 16:06:59
需求:显示2020/10/19
FormatDate(info) {
var date = new Date(info.replace(/-/g, '/'));
//注意:开始我直接传入封装成一个日期对象(var date = new Date(info);),如果得到的Y,M,D全是NAN //经高人指导要转成/
console.log(date);
let Y = date.getFullYear();
let M = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1);
let D = date.getDate() + ' ';
// let h = date.getHours() + ':';
// let m = date.getMinutes() + ':';
// let s = date.getSeconds();
return Y + '/' + M + '/' + D ;//+ '日' + h + m + s;
}