Commit 5de89b5ec542df4ab9b29b714253fa8d2fc1589f

Authored by GauharChan
Committed by GitHub
1 parent 0347c836

perf(demo): 动态更换表格配置 (#2793)

src/views/demo/table/RefTable.vue
... ... @@ -34,6 +34,7 @@
34 34 import { getBasicColumns, getBasicShortColumns } from './tableData';
35 35 import { useMessage } from '/@/hooks/web/useMessage';
36 36 import { demoListApi } from '/@/api/demo/table';
  37 +
37 38 export default defineComponent({
38 39 components: { BasicTable },
39 40 setup() {
... ... @@ -54,10 +55,22 @@
54 55 }, 1000);
55 56 }
56 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 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 75 getTableAction().reload({
63 76 page: 1,
... ...
src/views/demo/table/UseTable.vue
... ... @@ -25,6 +25,7 @@
25 25 import { getBasicColumns, getBasicShortColumns } from './tableData';
26 26 import { useMessage } from '/@/hooks/web/useMessage';
27 27 import { demoListApi } from '/@/api/demo/table';
  28 +
28 29 export default defineComponent({
29 30 components: { BasicTable },
30 31 setup() {
... ... @@ -36,7 +37,7 @@
36 37 registerTable,
37 38 {
38 39 setLoading,
39   - setColumns,
  40 + setProps,
40 41 getColumns,
41 42 getDataSource,
42 43 getRawDataSource,
... ... @@ -76,11 +77,22 @@
76 77 }, 1000);
77 78 }
78 79 function changeColumns() {
79   - setColumns(getBasicShortColumns());
  80 + setProps({
  81 + columns: getBasicShortColumns(),
  82 + rowSelection: {
  83 + type: 'checkbox',
  84 + },
  85 + showIndexColumn: true,
  86 + });
80 87 }
81 88 function reloadTable() {
82   - setColumns(getBasicColumns());
83   -
  89 + setProps({
  90 + columns: getBasicColumns(),
  91 + rowSelection: {
  92 + type: 'checkbox',
  93 + },
  94 + showIndexColumn: true,
  95 + });
84 96 reload({
85 97 page: 1,
86 98 });
... ...