<el-table
        :data="tableData"
        stripe
        style="width: 100%">
        <el-table-column
          prop="createdTime"
          label="日期"
          width="180" :formatter="formatDate">
        </el-table-column>
        <el-table-column
          prop="userName"
          label="用户"
          width="180">
        </el-table-column>
        <el-table-column
          prop="actionType"
          label="类型">
        </el-table-column>
        <el-table-column
          prop="actionStatus"
          label="状态">
        </el-table-column>
        <el-table-column
          prop="address"
          label="详情">
          <template slot-scope="scope">
            <el-button type="text"style="font-size: 30px">···</el-button>
          </template>
        </el-table-column>
  </el-table>
  data(){
      return{
          tableData:[]
      }
  }
  methods:{
      formatDate(value){
        <!--例如后台传给我们的时间戳  -->
          this.value1= new Date(value.createdTime);//value.createdTime是prop绑定的字段名称
          let dateValue = this.$moment(this.value1).format("YYYY-MM-DD HH:mm:ss");//$moment专门转化时间的插件(使用时需要下载引入)
          return dateValue
      }
  }
  重点:在要用的那一行:formatter="formatDate"//formatDate初始化的函数名称(除了时间,需要初始化的数据都可用它)复制代码
Logo

前往低代码交流专区

更多推荐