当前位置:   article > 正文

Element-UI表格固定_el-table-column 固定值

el-table-column 固定值

参考官网。横向的进度条代码。

  1. <template>
  2. <el-table
  3. :data="tableData"
  4. border
  5. style="width: 100%">
  6. <el-table-column
  7. fixed //固定列,默认为left,相当于fixed="left"
  8. prop="date"
  9. label="日期"
  10. width="150">
  11. </el-table-column>
  12. <el-table-column
  13. prop="name"
  14. label="姓名"
  15. width="120">
  16. </el-table-column>
  17. <el-table-column
  18. prop="province"
  19. label="省份"
  20. width="120">
  21. </el-table-column>
  22. <el-table-column
  23. prop="city"
  24. label="市区"
  25. width="120">
  26. </el-table-column>
  27. <el-table-column
  28. prop="address"
  29. label="地址"
  30. width="300">
  31. </el-table-column>
  32. <el-table-column
  33. prop="zip"
  34. label="邮编"
  35. width="120">
  36. </el-table-column>
  37. <el-table-column
  38. fixed="right"//固定列,靠右固定。
  39. label="操作"
  40. width="100">
  41. <template slot-scope="scope">
  42. <el-button @click="handleClick(scope.row)" type="text" size="small">查看</el-button>
  43. <el-button type="text" size="small">编辑</el-button>
  44. </template>
  45. </el-table-column>
  46. </el-table>
  47. </template>
  48. <script>
  49. export default {
  50. methods: {
  51. handleClick(row) {
  52. console.log(row);
  53. }
  54. },
  55. data() {
  56. return {
  57. tableData: [{
  58. date: '2016-05-02',
  59. name: '王小虎',
  60. province: '上海',
  61. city: '普陀区',
  62. address: '上海市普陀区金沙江路 1518 弄',
  63. zip: 200333
  64. }, {
  65. date: '2016-05-04',
  66. name: '王小虎',
  67. province: '上海',
  68. city: '普陀区',
  69. address: '上海市普陀区金沙江路 1517 弄',
  70. zip: 200333
  71. }, {
  72. date: '2016-05-01',
  73. name: '王小虎',
  74. province: '上海',
  75. city: '普陀区',
  76. address: '上海市普陀区金沙江路 1519 弄',
  77. zip: 200333
  78. }, {
  79. date: '2016-05-03',
  80. name: '王小虎',
  81. province: '上海',
  82. city: '普陀区',
  83. address: '上海市普陀区金沙江路 1516 弄',
  84. zip: 200333
  85. }]
  86. }
  87. }
  88. }
  89. </script>

纵向固定的代码:

  1. <template>
  2. <el-table
  3. :data="tableData"
  4. height="250" //设定高度就行了,固定了高度
  5. border
  6. style="width: 100%">
  7. <el-table-column
  8. prop="date"
  9. label="日期"
  10. width="180">
  11. </el-table-column>
  12. <el-table-column
  13. prop="name"
  14. label="姓名"
  15. width="180">
  16. </el-table-column>
  17. <el-table-column
  18. prop="address"
  19. label="地址">
  20. </el-table-column>
  21. </el-table>
  22. </template>
  23. <script>
  24. export default {
  25. data() {
  26. return {
  27. tableData: [{
  28. date: '2016-05-03',
  29. name: '王小虎',
  30. address: '上海市普陀区金沙江路 1518 弄'
  31. }, {
  32. date: '2016-05-02',
  33. name: '王小虎',
  34. address: '上海市普陀区金沙江路 1518 弄'
  35. }, {
  36. date: '2016-05-04',
  37. name: '王小虎',
  38. address: '上海市普陀区金沙江路 1518 弄'
  39. }, {
  40. date: '2016-05-01',
  41. name: '王小虎',
  42. address: '上海市普陀区金沙江路 1518 弄'
  43. }, {
  44. date: '2016-05-08',
  45. name: '王小虎',
  46. address: '上海市普陀区金沙江路 1518 弄'
  47. }, {
  48. date: '2016-05-06',
  49. name: '王小虎',
  50. address: '上海市普陀区金沙江路 1518 弄'
  51. }, {
  52. date: '2016-05-07',
  53. name: '王小虎',
  54. address: '上海市普陀区金沙江路 1518 弄'
  55. }]
  56. }
  57. }
  58. }
  59. </script>

 

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/AllinToyou/article/detail/581722
推荐阅读
相关标签