当前位置:   article > 正文

vue使用element-ui的表格,实现各行换色

element ui table一行蓝色一行绿色
  1. <el-table
  2. :data="tableData"
  3. :header-cell-style="tableHeaderColor"//头部变色
  4. style="width: 100%" :row-class-name="tableRowClassName"//隔行换色
  5. >
  6. <el-table-column
  7. align='center'
  8. label="日期" width="60">
  9. <el-table-column prop="date" align='center'>
  10. </el-table-column>
  11. </el-table-column>
  12. <el-table-column
  13. align='center'
  14. label="产品型号" width="80">
  15. <el-table-column prop="ProductModel" align='center'>
  16. </el-table-column>
  17. </el-table-column>
  18. <el-table-column label="喷淋链速" width="120" align='center'>
  19. <el-table-column
  20. prop="spray.spraySet"
  21. align='center'
  22. label="设定" width="60">
  23. </el-table-column>
  24. <el-table-column
  25. prop="spray.sprayCur"
  26. align='center'
  27. label="实际" width="60">
  28. </el-table-column>
  29. </el-table-column>
  30. <el-table-column label="喷淋风刀频率" width="120" align='center'>
  31. <el-table-column
  32. prop="rate.rateSet"
  33. align='center'
  34. label="设定" width="60">
  35. </el-table-column>
  36. <el-table-column
  37. prop="rate.rateCur"
  38. align='center'
  39. label="实际" width="60">
  40. </el-table-column>
  41. </el-table-column>
  42. <el-table-column
  43. align='center'
  44. label="氧气浓度">
  45. <el-table-column prop="O2" align='center'>
  46. </el-table-column>
  47. </el-table-column>
  48. <el-table-column
  49. align='center'
  50. label="氮气浓度" >
  51. <el-table-column prop="N2" align='center'>
  52. </el-table-column>
  53. </el-table-column>
  54. <el-table-column label="干燥炉" width="300" align='center'>
  55. <el-table-column label="1区" width="100" align='center'>
  56. <el-table-column
  57. prop="Dry.Dryone.DryoneSet"
  58. align='center'
  59. label="设定" width="50">
  60. </el-table-column>
  61. <el-table-column
  62. prop="Dry.Dryone.DryoneCur"
  63. align='center'
  64. label="实际" width="50">
  65. </el-table-column>
  66. </el-table-column>
  67. <el-table-column label="2区" width="100" align='center'>
  68. <el-table-column
  69. prop="Dry.Drytwo.DrytwoSet"
  70. align='center'
  71. label="设定" width="50">
  72. </el-table-column>
  73. <el-table-column
  74. prop="Dry.Drytwo.DrytwoCur"
  75. align='center'
  76. label="实际" width="50">
  77. </el-table-column>
  78. </el-table-column>
  79. <el-table-column label="3区" width="100" align='center'>
  80. <el-table-column
  81. prop="Dry.Drythree.DrythreeSet"
  82. align='center'
  83. label="设定" width="50">
  84. </el-table-column>
  85. <el-table-column
  86. prop="Dry.Drythree.DrythreeCur"
  87. align='center'
  88. label="实际" width="50">
  89. </el-table-column>
  90. </el-table-column>
  91. </el-table-column>
  92. <el-table-column label="预热炉" width="300" align='center'>
  93. <el-table-column label="1区" width="100" align='center'>
  94. <el-table-column
  95. prop="Hot.Hotone.HotoneSet"
  96. align='center'
  97. label="设定" width="50">
  98. </el-table-column>
  99. <el-table-column
  100. prop="Hot.Hotone.HotoneCur"
  101. align='center'
  102. label="实际" width="50">
  103. </el-table-column>
  104. </el-table-column>
  105. <el-table-column label="2区" width="100" align='center'>
  106. <el-table-column
  107. prop="Hot.Hottwo.HottwoSet"
  108. align='center'
  109. label="设定" width="50">
  110. </el-table-column>
  111. <el-table-column
  112. prop="Hot.Hottwo.HottwoCur"
  113. align='center'
  114. label="实际" width="50">
  115. </el-table-column>
  116. </el-table-column>
  117. <el-table-column label="3区" width="100" align='center'>
  118. <el-table-column
  119. prop="Hot.Hotthree.HotthreeSet"
  120. align='center'
  121. label="设定" width="50">
  122. </el-table-column>
  123. <el-table-column
  124. prop="Hot.Hotthree.HotthreeCur"
  125. align='center'
  126. label="实际" width="50">
  127. </el-table-column>
  128. </el-table-column>
  129. </el-table-column>
  130. <el-table-column label="钎焊炉" width="300" align='center'>
  131. <el-table-column label="1区" width="100" align='center'>
  132. <el-table-column
  133. prop="Brazing.Brazingone.BrazingoneSet"
  134. align='center'
  135. label="设定" width="50">
  136. </el-table-column>
  137. <el-table-column
  138. prop="Brazing.Brazingone.BrazingoneCur"
  139. align='center'
  140. label="实际" width="50">
  141. </el-table-column>
  142. </el-table-column>
  143. <el-table-column label="2区" width="100" align='center'>
  144. <el-table-column
  145. prop="Brazing.Brazingtwo.BrazingtwoSet"
  146. align='center'
  147. label="设定" width="50">
  148. </el-table-column>
  149. <el-table-column
  150. prop="Brazing.Brazingtwo.BrazingtwoCur"
  151. align='center'
  152. label="实际" width="50">
  153. </el-table-column>
  154. </el-table-column>
  155. <el-table-column label="3区" width="100" align='center'>
  156. <el-table-column
  157. prop="Brazing.Brazingthree.BrazingthreeSet"
  158. align='center'
  159. label="设定" width="50">
  160. </el-table-column>
  161. <el-table-column
  162. prop="Brazing.Brazingthree.BrazingthreeCur"
  163. align='center'
  164. label="实际" width="50">
  165. </el-table-column>
  166. </el-table-column>
  167. </el-table-column>
  168. </el-table>
  169. methods:{
  170. tableRowClassName({row, rowIndex}) {
  171. if(rowIndex%2==1){
  172. return 'warning-row';
  173. }else{
  174. return 'success-row';
  175. }
  176. },
  177. // 修改table header的背景色
  178. tableHeaderColor({ row, column, rowIndex, columnIndex }) {
  179. if (rowIndex === 0) {
  180. return 'background-color: #ebf1fb;color: #496fec;font-weight:600;font-size:16px;text-align:center'
  181. }else if(rowIndex === 1){
  182. return 'background-color: #f7faff;font-size:14px;text-align:center'
  183. }else if(rowIndex === 2){
  184. return 'background-color: #f7faff;font-size:14px;text-align:center'
  185. }
  186. },
  187. }
  188. <style>
  189. .el-table .warning-row {
  190. background: #f7faff;
  191. }
  192. .el-table .success-row {
  193. background: #ebf1fb;
  194. }
  195. </style>复制代码
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/IT小白/article/detail/241827
推荐阅读
相关标签