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


     

    1. <template>
    2. <div class="table-wrapper">
    3. <el-table
    4. :header-cell-style="getRowClass"
    5. :row-class-name="tableRowClassName"
    6. :data="tableData"
    7. style="width: 100%;color:#fff; font-size: 12px;margin:0 auto;"
    8. ref="tableXj1"
    9. height="278px"
    10. >
    11. <el-table-column
    12. label="设备名称"
    13. prop="MACHINENAME"
    14. min-width="40"
    15. align="center"
    16. >
    17. </el-table-column>
    18. <el-table-column
    19. label="设备名称"
    20. prop="MACHINENAME"
    21. min-width="40"
    22. align="center"
    23. >
    24. </el-table-column>
    25. <el-table-column
    26. label="设备名称"
    27. prop="MACHINENAME"
    28. min-width="40"
    29. align="center"
    30. >
    31. </el-table-column>
    32. <el-table-column
    33. label="异常现象"
    34. prop="FAULTDESCRIBE"
    35. min-width="40"
    36. align="center"
    37. >
    38. </el-table-column>
    39. <el-table-column
    40. label="设备名称"
    41. prop="MACHINENAME"
    42. min-width="40"
    43. align="center"
    44. >
    45. </el-table-column>
    46. <el-table-column
    47. label="设备名称"
    48. prop="MACHINENAME"
    49. min-width="40"
    50. align="center"
    51. >
    52. </el-table-column>
    53. </el-table>
    54. </div>
    55. </template>
    56. <script>
    57. export default {
    58. data() {
    59. return {
    60. intervalId: null,
    61. tableData: [
    62. { MACHINENAME: 10001, FAULTDESCRIBE: 'Test1' },
    63. { MACHINENAME: 10002, FAULTDESCRIBE: 'Test2' },
    64. { MACHINENAME: 10003, FAULTDESCRIBE: 'Test3' },
    65. { MACHINENAME: 10004, FAULTDESCRIBE: 'Test4' },
    66. { MACHINENAME: 10004, FAULTDESCRIBE: 'Test4' },
    67. { MACHINENAME: 10004, FAULTDESCRIBE: 'Test4' },
    68. { MACHINENAME: 10004, FAULTDESCRIBE: 'Test4' },
    69. { MACHINENAME: 10004, FAULTDESCRIBE: 'Test4' },
    70. { MACHINENAME: 10004, FAULTDESCRIBE: 'Test4' },
    71. { MACHINENAME: 10004, FAULTDESCRIBE: 'Test4' },
    72. ],
    73. }
    74. },
    75. mounted: function () {
    76. const tableXj1 = this.$refs.tableXj1
    77. const divDataXj1 = tableXj1.bodyWrapper
    78. this.intervalId = setInterval(() => {
    79. divDataXj1.scrollTop += 2
    80. if (divDataXj1.clientHeight + divDataXj1.scrollTop == divDataXj1.scrollHeight) {
    81. divDataXj1.scrollTop = 0
    82. }
    83. }, 100)
    84. },
    85. methods: {
    86. // 设置隔行变色
    87. tableRowClassName({ rowIndex }) {
    88. if (rowIndex % 2 === 0) {
    89. return 'yellow'
    90. } else {
    91. return 'orange'
    92. }
    93. },
    94. getRowClass({ row, column, rowIndex, columnIndex }) {
    95. return "background:rgba(31, 94, 167, 0.4);color:#326aff";
    96. },
    97. },
    98. beforeDestroy() {
    99. clearInterval(this.intervalId);
    100. },
    101. }
    102. </script>
    103. <style scoped>
    104. .table-wrapper /deep/ .el-table .el-table__body-wrapper {
    105. overflow-y: hidden !important;
    106. }
    107. .table-wrapper /deep/.el-table,
    108. .el-table__expanded-cell {
    109. background-color: transparent !important;
    110. }
    111. .table-wrapper /deep/ tr,
    112. .table-wrapper /deep/ th,
    113. .table-wrapper /deep/ td {
    114. border-bottom: 0px;
    115. }
    116. .table-wrapper >>> .el-table__row > td {
    117. border: none;
    118. }
    119. .table-wrapper >>> .el-table th.el-table__cell.is-leaf {
    120. border-bottom: none !important;
    121. }
    122. .table-wrapper >>> .el-table__inner-wrapper::before {
    123. height: 0;
    124. }
    125. ::v-deep .el-table__body {
    126. -webkit-border-vertical-spacing: 13px;
    127. border: none !important;
    128. }
    129. ::v-deep .yellow {
    130. border: none !important;
    131. 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;
    132. }
    133. ::v-deep .orange {
    134. 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;
    135. }
    136. .table-wrapper /deep/ .el-table th > .cell {
    137. color: #fff !important;
    138. border: none !important;
    139. }
    140. .table-wrapper /deep/ .el-table--fit {
    141. padding: 20px;
    142. }
    143. .table-wrapper /deep/ .el-table tr {
    144. background-color: transparent !important;
    145. border: none !important;
    146. }
    147. .table-wrapper /deep/ .el-table th > .cell {
    148. color: #fff !important;
    149. }
    150. .table-wrapper /deep/ .el-table--fit {
    151. padding: 20px;
    152. }
    153. .table-wrapper /deep/ .el-table,
    154. .el-table__expanded-cell {
    155. background-color: transparent;
    156. }
    157. .table-wrapper /deep/ .el-table tr {
    158. background-color: transparent !important;
    159. }
    160. .table-wrapper /deep/ .el-table--enable-row-transition .el-table__body td,
    161. .el-table .cell {
    162. background-color: transparent;
    163. }
    164. </style>

  • 相关阅读:
    【Compose】Desktop Application 初尝试
    快速体验 Flink Table Store 入门篇
    Java的构造器 / 构造方法
    KY95 Old Bill
    C/C++关于main函数参数问题
    Python 知识点
    SwiftUI 4.0(iOS 16+)使用新的 Gauge 视图极简实现仪表盘外观
    JAVA经典百题之判断星期几
    [RISC-V]verilog
    Android简易音乐重构MVVM Java版-使用Navigation导航组件重构主界面及其他页面跳转(二十)
  • 原文地址:https://blog.csdn.net/cjy_fly/article/details/140987377