web建站教程
  1. 首页
  2. vuejs
  3. js
  4. 好玩
  5. seo教程
  6. 前端知识
  7. 百度echarts
  8. 更多
    php入门
    nodejs
    mockjs
    reactjs
    mysql
    wordpress
    织梦cms
    帝国cms
    git教程
    IT知识
    模板大全
    休息站

el-table列表给指定列的文字添加样式,但是列是动态的

508 ℃
     

功能要求:需要给el-table中的其中一列的新增颜色(不同类型不同颜色),但是这列的位置是根据不同用户变化的,用户A登录在第二列、用户B登录在第七列。

<el-table :data="listData" v-loading="dataLoading" :cell-class-name="myclass"></el-table>

解决方法:

myclass({ row, column, rowIndex, columnIndex }) {
   //在需要属性中判断
  if (column.property === 'type') {
    //需要拿到id="el-table_1_column_1" 最后的数字-1就是当前的位置
    const columnArr = column.id.split('_')
    let currentIndex = Number(columnArr[columnArr.length - 1]) - 1 //获取type属性位置

    //根据不同类型判断
    if (row.type == '语文' && columnIndex === currentIndex) {
       return 'color1'
    } else if (row.type == '英文' && columnIndex === currentIndex) {
       return 'color2'
    } else if (row.type == '数学' && columnIndex === currentIndex) {
       return 'color3'
    } else if (row.type == '体育' && columnIndex === currentIndex) {
       return 'color4'
    } else if (row.type == '自习' && columnIndex === currentIndex) {
       return 'color5'
    }
  }
}

el-table表格显示selection多选时对某些复选框设置禁止选中

el-table表格实现多选功能(全选/指定选中/取消选中)

el-table实现拖拽行排序sortablejs

el-dialog中获取el-table组件的ref值报undefined错误!

el-table合并单元格代码介绍

标签: el-table

上面是“el-table列表给指定列的文字添加样式,但是列是动态的”的全面内容,想了解更多关于 vuejs 内容,请继续关注web建站教程。

当前网址:https://ipkd.cn/webs_3459.html

声明:本站提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请发送到邮箱:admin@ipkd.cn,我们会在看到邮件的第一时间内为您处理!

当前位置: 网站首页 > vuejs
本文共计733个字,预计阅读时长5分钟
生活小工具,收录了80多款小工具
上一篇: 推荐一款简单高效漂亮的多平台笔记应用——Zoho Notebook
下一篇: 推荐2款充满科技感的艺术字体——小新黑体、小新潮酷体
x 打工人ai神器