//定义格式化函数: handleTime(time, format) { if (time == null || time == undefined || time == "") { return ""; } var t = new Date(time); var tf = function (i) { return (i < 10 ? '0' : '') + i }; return format.replace(/yyyy|MM|dd|HH|mm|ss/g, function (a) { switch (a) { case 'yyyy': return tf(t.getFullYear()); break; case 'MM': return tf(t.getMonth() + 1); break; case 'mm': return tf(t.getMinutes()); break; case 'dd': return tf(t.getDate()); break; case 'HH': return tf(t.getHours()); break; case 'ss': return tf(t.getSeconds()); break; } }) }, //调用函数handleTime(timeRange.range[0], "yyyy-MM-dd HH:mm:ss");
标签:case,break,格式化,React,标准,time,tf,return,yyyy From: https://www.cnblogs.com/Esai-Z/p/17408481.html