vue之el-table某一列设置样式

川长思鸟来 2023-01-17 02:23 194阅读 0赞

方法一

在el-table设置属性cell-style方法
  1. <el-table
  2. :cell-style="setRowStyle">
  3. .........
  4. </el-table>
在method中设置
  1. setRowStyle(row, column, rowIndex, columnIndex) {
  2. if(row.status=== "1"){
  3. return 'color: green'
  4. }else{
  5. return 'color: red'
  6. }
  7. }

方法二

  1. <el-table-column prop="status" label="状态">
  2. <template scope="scope">
  3. <span v-if="scope.row.status==='1'" style="color: green">成功</span>
  4. <span v-else-if="scope.row.status==='2'">失败</span>
  5. <span v-else style="color: red">未知</span>
  6. </template>
  7. </el-table-column>

发表评论

表情:
评论列表 (有 0 条评论,194人围观)

还没有评论,来说两句吧...

相关阅读