举个例子如下:
<div style="display:inline-block;margin-left:20px;" v-show="showUpdate"> <span>上次汇总时间:</span> <span>{{items.length>0?dateFormat( items[0].sumLasttime):"请手动汇总更新汇总数据"}}</span> </div>
<span>{{items.length>0?dateFormat( items[0].sumLasttime):"请手动汇总更新汇总数据"}}</span>
把后台传来的时间传入自定义的日期时间规范化函数里面,在js函数里面弄成自己想要的日期时间,下面是一个例子:
dateFormat(time) { var date = new Date(time); var year = date.getFullYear(); var month = date.getMonth() + 1 < 10 ? "0" + (date.getMonth() + 1) : date.getMonth() + 1; var day = date.getDate() < 10 ? "0" + date.getDate() : date.getDate(); var hours = date.getHours() < 10 ? "0" + date.getHours() : date.getHours(); var minutes = date.getMinutes() < 10 ? "0" + date.getMinutes() : date.getMinutes(); var seconds = date.getSeconds() < 10 ? "0" + date.getSeconds() : date.getSeconds(); return ( year + "-" + month + "-" + day + " " + hours + ":" + minutes + ":" + seconds ); }