<td>{{serverInfo.serverTime| formatTime(‘YMDHMS‘)}}</td>
js
serverTime: new Date().getTime(),
filters: { // 时间过滤器 formatTime: function(value, type) { let dataTime = ""; let data = new Date(); data.setTime(value); let year = data.getFullYear(); let month = data.getMonth() + 1; let day = data.getDate(); let hour = data.getHours(); let minute = data.getMinutes(); let second = data.getSeconds(); if (month < 10) { month = "0" + month; } if (day < 10) { day = "0" + day; } if (hour < 10) { hour = "0" + hour; } if (minute < 10) { minute = "0" + minute; } if (second < 10) { second = "0" + second; } if (type == "YMD") { dataTime = year + "-" + month + "-" + day; } else if (type == "YMDHMS") { dataTime = year + "-" + month + "-" + day + " " + hour + ":" + minute + ":" + second; } else if (type == "HMS") { dataTime = hour + ":" + minute + ":" + second; } else if (type == "YM") { dataTime = year + "-" + month + "-"; } return dataTime; // 将格式化后的字符串输出到前端显示 } },