Commit 5de89b5ec542df4ab9b29b714253fa8d2fc1589f
Committed by
GitHub
1 parent
0347c836
perf(demo): 动态更换表格配置 (#2793)
Showing
2 changed files
with
31 additions
and
6 deletions
src/views/demo/table/RefTable.vue
@@ -34,6 +34,7 @@ | @@ -34,6 +34,7 @@ | ||
34 | import { getBasicColumns, getBasicShortColumns } from './tableData'; | 34 | import { getBasicColumns, getBasicShortColumns } from './tableData'; |
35 | import { useMessage } from '/@/hooks/web/useMessage'; | 35 | import { useMessage } from '/@/hooks/web/useMessage'; |
36 | import { demoListApi } from '/@/api/demo/table'; | 36 | import { demoListApi } from '/@/api/demo/table'; |
37 | + | ||
37 | export default defineComponent({ | 38 | export default defineComponent({ |
38 | components: { BasicTable }, | 39 | components: { BasicTable }, |
39 | setup() { | 40 | setup() { |
@@ -54,10 +55,22 @@ | @@ -54,10 +55,22 @@ | ||
54 | }, 1000); | 55 | }, 1000); |
55 | } | 56 | } |
56 | function changeColumns() { | 57 | function changeColumns() { |
57 | - getTableAction().setColumns(getBasicShortColumns()); | 58 | + getTableAction().setProps({ |
59 | + columns: getBasicShortColumns(), | ||
60 | + rowSelection: { | ||
61 | + type: 'checkbox', | ||
62 | + }, | ||
63 | + showIndexColumn: true, | ||
64 | + }); | ||
58 | } | 65 | } |
59 | function reloadTable() { | 66 | function reloadTable() { |
60 | - getTableAction().setColumns(getBasicColumns()); | 67 | + getTableAction().setProps({ |
68 | + columns: getBasicColumns(), | ||
69 | + rowSelection: { | ||
70 | + type: 'checkbox', | ||
71 | + }, | ||
72 | + showIndexColumn: true, | ||
73 | + }); | ||
61 | 74 | ||
62 | getTableAction().reload({ | 75 | getTableAction().reload({ |
63 | page: 1, | 76 | page: 1, |
src/views/demo/table/UseTable.vue
@@ -25,6 +25,7 @@ | @@ -25,6 +25,7 @@ | ||
25 | import { getBasicColumns, getBasicShortColumns } from './tableData'; | 25 | import { getBasicColumns, getBasicShortColumns } from './tableData'; |
26 | import { useMessage } from '/@/hooks/web/useMessage'; | 26 | import { useMessage } from '/@/hooks/web/useMessage'; |
27 | import { demoListApi } from '/@/api/demo/table'; | 27 | import { demoListApi } from '/@/api/demo/table'; |
28 | + | ||
28 | export default defineComponent({ | 29 | export default defineComponent({ |
29 | components: { BasicTable }, | 30 | components: { BasicTable }, |
30 | setup() { | 31 | setup() { |
@@ -36,7 +37,7 @@ | @@ -36,7 +37,7 @@ | ||
36 | registerTable, | 37 | registerTable, |
37 | { | 38 | { |
38 | setLoading, | 39 | setLoading, |
39 | - setColumns, | 40 | + setProps, |
40 | getColumns, | 41 | getColumns, |
41 | getDataSource, | 42 | getDataSource, |
42 | getRawDataSource, | 43 | getRawDataSource, |
@@ -76,11 +77,22 @@ | @@ -76,11 +77,22 @@ | ||
76 | }, 1000); | 77 | }, 1000); |
77 | } | 78 | } |
78 | function changeColumns() { | 79 | function changeColumns() { |
79 | - setColumns(getBasicShortColumns()); | 80 | + setProps({ |
81 | + columns: getBasicShortColumns(), | ||
82 | + rowSelection: { | ||
83 | + type: 'checkbox', | ||
84 | + }, | ||
85 | + showIndexColumn: true, | ||
86 | + }); | ||
80 | } | 87 | } |
81 | function reloadTable() { | 88 | function reloadTable() { |
82 | - setColumns(getBasicColumns()); | ||
83 | - | 89 | + setProps({ |
90 | + columns: getBasicColumns(), | ||
91 | + rowSelection: { | ||
92 | + type: 'checkbox', | ||
93 | + }, | ||
94 | + showIndexColumn: true, | ||
95 | + }); | ||
84 | reload({ | 96 | reload({ |
85 | page: 1, | 97 | page: 1, |
86 | }); | 98 | }); |