可在后端处理
1.在实体类中加注解
在实体类中加入下列代码,我是这样处理的(我是在往前台传展示的时候发现的这个问题)
@JsonFormat(timezone = “GMT+8”,pattern = “yyyy-MM-dd HH:mm:ss”)
直接修改传值的时间戳。
2.前端处理
使用VUE elementui框架,在表格中直接处理对应的错误字段即可。
<el-table-column
prop="createDate"
align="center"
label="创建时间"
width="150">
<template slot-scope="scope" v-if="scope.row.createDate">
{{scope.row.createDate.toLocaleString().replace(/T/g, ' ').replace(/\.[\d]{3}Z/, '')}}
</template>
</el-table-column>
使用时注意加判断,v-if=“scope.row.createDate”
当前时间.replace(/T/g, ’ ').replace(/.[\d]{3}Z/, ’ ') 即可去掉T ;

博客介绍了前后端处理时间戳显示问题的方法。后端可在实体类中加注解 @JsonFormat 直接修改传值的时间戳;前端使用 VUE elementui 框架,在表格中处理对应错误字段,加判断 v-if=“scope.row.createDate”,并通过替换去掉时间中的 T。
1039

被折叠的 条评论
为什么被折叠?



