UnfixedThead.vue 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <template>
  2. <div class="app-container">
  3. <div class="filter-container">
  4. <el-checkbox-group v-model="formThead">
  5. <el-checkbox label="apple">
  6. apple
  7. </el-checkbox>
  8. <el-checkbox label="banana">
  9. banana
  10. </el-checkbox>
  11. <el-checkbox label="orange">
  12. orange
  13. </el-checkbox>
  14. </el-checkbox-group>
  15. </div>
  16. <el-table :data="tableData" border fit highlight-current-row style="width: 100%">
  17. <el-table-column prop="name" label="fruitName" width="180" />
  18. <el-table-column v-for="fruit in formThead" :key="fruit" :label="fruit">
  19. <template slot-scope="scope">
  20. {{ scope.row[fruit] }}
  21. </template>
  22. </el-table-column>
  23. </el-table>
  24. </div>
  25. </template>
  26. <script>
  27. export default {
  28. data() {
  29. return {
  30. tableData: [
  31. {
  32. name: 'fruit-1',
  33. apple: 'apple-10',
  34. banana: 'banana-10',
  35. orange: 'orange-10'
  36. },
  37. {
  38. name: 'fruit-2',
  39. apple: 'apple-20',
  40. banana: 'banana-20',
  41. orange: 'orange-20'
  42. }
  43. ],
  44. formThead: ['apple', 'banana']
  45. }
  46. }
  47. }
  48. </script>