这个函数是通过传入的date对象返回 “yyyy-MM-dd HH:mm:ss”格式的时间字符串
formatDate(date){
date = date instanceof Date ? date : new Date();
const pad = (val)=> {
val = String(val);
while (val.length < 2) { val = '0' + val; }
return val;
};
return pad(date.getFullYear()) +'-'+pad(date.getMonth()+1)+'-'+pad(date.getDate())+' '+pad(date.getHours())+':'+pad(date.getMinutes())+':'+pad(date.getSeconds())
},