<template v-if="scope.row.edit"> <el-date-picker class="stra-date-picker" size="small" v-model="scope.row.publish_time" type="date" placeholder="请选择日期"> </el-date-picker> </template> <span v-else class="db ell" :title="scope.row.publish_time">{{ scope.row.publish_time }}</span>
选择日期的时候格式并无问题,以下:web
因为在官方文档中,有提到能够使用changebash
<el-date-picker type="date" v-model="time" @change="formatTime" format="yyyy-MM-dd" placeholder="请选择日期"></el-date-picker>
而后在methods中,添加一个方法便可,代码以下:ui
formatTime(val) { this.time=val; }
这个方法是直接将v-model里面的值改变,但因为个人项目日期里面v-model的值,是整个动态循环绑定的,不能知道当前的time值,因此可用下面的方法2this
代码以下:spa
<template v-if="scope.row.edit"> <el-date-picker class="stra-date-picker" size="small" v-model="scope.row.publish_time" type="date" value-format="yyyy-MM-dd" placeholder="请选择日期"> </el-date-picker> </template> <span v-else class="db ell" :title="scope.row.publish_time">{{ scope.row.publish_time }}</span>
效果以下:code