查询头
<el-form-item label="检验时间:" prop="date"> <el-date-picker v-model="queryParams.date" type="date" placeholder="请选择" clearable size="small" value-format="yyyy-MM-dd" /> </el-form-item>
表格
<el-table v-loading="loading" :data="tableData1"> <template slot="empty"> <div style="height: 500px"> <img src="@/assets/image/zwsj.png" alt="" /> <div style=" display: flex; height: 32px; align-items: center; justify-content: center; " > <p style="color: #333; font-size: 14px">暂无数据</p> </div> </div> </template> <el-table-column prop="date" label="时间" :formatter="formatDateTime"> </el-table-column> </el-table>
js
// 日期格式转换 formatDateTime(row) { const rawDateTime = row.date; if (rawDateTime) { const dateObj = new Date(rawDateTime); const year = dateObj.getFullYear(); const month = ("0" + (dateObj.getMonth() + 1)).slice(-2); const date = ("0" + dateObj.getDate()).slice(-2); const hours = ("0" + dateObj.getHours()).slice(-2); const minutes = ("0" + dateObj.getMinutes()).slice(-2); const seconds = ("0" + dateObj.getSeconds()).slice(-2); return `${year}-${month}-${date} ${hours}:${minutes}:${seconds}`; } else { return ""; } },
标签:vue,const,rawDateTime,element,slice,ui,date,dateObj,查询 From: https://www.cnblogs.com/tingorb/p/18310075