vue elementUI table表格自定义样式滚动

<template>
  <div class="table-wrapper">
    <el-table
      :header-cell-style="getRowClass"
      :row-class-name="tableRowClassName"
      :data="tableData"
      style="width: 100%;color:#fff; font-size: 12px;margin:0 auto;"
      ref="tableXj1"
      height="278px"
    >
      <el-table-column
        label="设备名称"
        prop="MACHINENAME"
        min-width="40"
        align="center"
      >
      </el-table-column>
      <el-table-column
        label="设备名称"
        prop="MACHINENAME"
        min-width="40"
        align="center"
      >
      </el-table-column>
      <el-table-column
        label="设备名称"
        prop="MACHINENAME"
        min-width="40"
        align="center"
      >
      </el-table-column>
      <el-table-column
        label="异常现象"
        prop="FAULTDESCRIBE"
        min-width="40"
        align="center"
      >
      </el-table-column>
      <el-table-column
        label="设备名称"
        prop="MACHINENAME"
        min-width="40"
        align="center"
      >
      </el-table-column>
      <el-table-column
        label="设备名称"
        prop="MACHINENAME"
        min-width="40"
        align="center"
      >
      </el-table-column>
    </el-table>
  </div>
</template>
<script>

export default {
  data() {
    return {
      intervalId: null,
      tableData: [
        { MACHINENAME: 10001, FAULTDESCRIBE: 'Test1' },
        { MACHINENAME: 10002, FAULTDESCRIBE: 'Test2' },
        { MACHINENAME: 10003, FAULTDESCRIBE: 'Test3' },
        { MACHINENAME: 10004, FAULTDESCRIBE: 'Test4' },
        { MACHINENAME: 10004, FAULTDESCRIBE: 'Test4' },
        { MACHINENAME: 10004, FAULTDESCRIBE: 'Test4' },
        { MACHINENAME: 10004, FAULTDESCRIBE: 'Test4' },
        { MACHINENAME: 10004, FAULTDESCRIBE: 'Test4' },
        { MACHINENAME: 10004, FAULTDESCRIBE: 'Test4' },
        { MACHINENAME: 10004, FAULTDESCRIBE: 'Test4' },
      ],
    }
  },

  mounted: function () {
    const tableXj1 = this.$refs.tableXj1
    const divDataXj1 = tableXj1.bodyWrapper
    this.intervalId = setInterval(() => {
      divDataXj1.scrollTop += 2
      if (divDataXj1.clientHeight + divDataXj1.scrollTop == divDataXj1.scrollHeight) {
        divDataXj1.scrollTop = 0
      }
    }, 100)
  },
  methods: {
    // 设置隔行变色
    tableRowClassName({ rowIndex }) {
      if (rowIndex % 2 === 0) {
        return 'yellow'
      } else {
        return 'orange'
      }
    },
    getRowClass({ row, column, rowIndex, columnIndex }) {
      return "background:rgba(31, 94, 167, 0.4);color:#326aff";
    },
  },
  beforeDestroy() {
    clearInterval(this.intervalId);
  },
}
</script>
<style scoped>
.table-wrapper /deep/ .el-table .el-table__body-wrapper {
    overflow-y: hidden !important;
}
.table-wrapper /deep/.el-table,
.el-table__expanded-cell {
    background-color: transparent !important;
}
.table-wrapper /deep/ tr,
.table-wrapper /deep/ th,
.table-wrapper /deep/ td {
    border-bottom: 0px;
}
.table-wrapper >>> .el-table__row > td {
    border: none;
}
.table-wrapper >>> .el-table th.el-table__cell.is-leaf {
    border-bottom: none !important;
}
.table-wrapper >>> .el-table__inner-wrapper::before {
    height: 0;
}
::v-deep .el-table__body {
    -webkit-border-vertical-spacing: 13px;
    border: none !important;
}
::v-deep .yellow {
    border: none !important;
    background: linear-gradient(90deg, rgba(31, 94, 167, 0) 3%, rgba(31, 94, 167, 0.4) 40%, rgba(31, 94, 167, 0.4) 70%, rgba(31, 94, 167, 0) 100%) !important;
}
::v-deep .orange {
    background: linear-gradient(90deg, rgba(31, 94, 167, 0) 3%, rgba(31, 94, 167, 0.2) 50%, rgba(31, 94, 167, 0.2) 70%, rgba(31, 94, 167, 0) 100%) !important;
}
.table-wrapper /deep/ .el-table th > .cell {
    color: #fff !important;
    border: none !important;
}
.table-wrapper /deep/ .el-table--fit {
    padding: 20px;
}

.table-wrapper /deep/ .el-table tr {
    background-color: transparent !important;
    border: none !important;
}
.table-wrapper /deep/ .el-table th > .cell {
    color: #fff !important;
}
.table-wrapper /deep/ .el-table--fit {
    padding: 20px;
}
.table-wrapper /deep/ .el-table,
.el-table__expanded-cell {
    background-color: transparent;
}

.table-wrapper /deep/ .el-table tr {
    background-color: transparent !important;
}
.table-wrapper /deep/ .el-table--enable-row-transition .el-table__body td,
.el-table .cell {
    background-color: transparent;
}
</style>
相关推荐
熊的猫25 分钟前
JS 中的类型 & 类型判断 & 类型转换
前端·javascript·vue.js·chrome·react.js·前端框架·node.js
瑶琴AI前端1 小时前
uniapp组件实现省市区三级联动选择
java·前端·uni-app
会发光的猪。1 小时前
如何在vscode中安装git详细新手教程
前端·ide·git·vscode
mosen8681 小时前
Uniapp去除顶部导航栏-小程序、H5、APP适用
vue.js·微信小程序·小程序·uni-app·uniapp
别拿曾经看以后~2 小时前
【el-form】记一例好用的el-input输入框回车调接口和el-button按钮防重点击
javascript·vue.js·elementui
我要洋人死2 小时前
导航栏及下拉菜单的实现
前端·css·css3
科技探秘人2 小时前
Chrome与火狐哪个浏览器的隐私追踪功能更好
前端·chrome
科技探秘人2 小时前
Chrome与傲游浏览器性能与功能的深度对比
前端·chrome
JerryXZR2 小时前
前端开发中ES6的技术细节二
前端·javascript·es6
七星静香2 小时前
laravel chunkById 分块查询 使用时的问题
java·前端·laravel