写一个过滤器
getTime(item) { const date = new Date(
//这一步是根据我后端返回的时间格式处理的,可选用 item.replace(/\-/g, "/").substring(0, item.indexOf(".")) ); const Y = date.getFullYear() + "-"; const M = (date.getMonth() + 1 < 10 ? "0" + (date.getMonth() + 1) : date.getMonth() + 1) + "-"; const D = (date.getDate() < 10 ? "0" + date.getDate() : date.getDate()) + " "; const h = (date.getHours() < 10 ? "0" + date.getHours() : date.getHours()) + ":"; const m = (date.getMinutes() < 10 ? "0" + date.getMinutes() : date.getMinutes()) + ":"; const s = date.getSeconds() < 10 ? "0" + date.getSeconds() : date.getSeconds(); return Y + M + D + h + m + s; }
拿走不谢,我是金陵彭于晏我们下期再见!!!