项目场景:
vue动态表格内容中的时间戳转换:
<el-table v-loading="loading" :data="dataShow" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" align="center"/>
<div v-for="(item, index) in tableHead" :key="index">
<el-table-column :prop="item.column_name" :label="item.column_comment">
<span v-if="checkTime(item.column_name)" slot-scope="scope">
{{parseTime(scope.row[item.column_name],'{y}-{m}-{d} {h}:{m}:{s}')}}
</span>
<span v-else>
{{scope.row[item.column_name]}}
</span>
</el-table-column>
</div>
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template slot-scope="scope">
<el-button
size="mini"
type="text"
icon="el-icon-delete"
@click="handleDelete(scope.row)"
v-hasPermi="['game:notice:remove']"
>删除</el-button>
</template>
</el-table-column>
</el-table>
解决方案:
一个个判断列名是否包含"Time",目前还没想出更好的办法,记录下避免遗忘