From 62428b6df3e84b02a66c3d329c1c9c4bee411998 Mon Sep 17 00:00:00 2001 From: zkwolf Date: Mon, 17 Jan 2022 10:47:04 +0800 Subject: [PATCH] fix(table): responsive invalid (#5172) * fix(table): reponsive invalid #5171 * docs(table): add reponsive demo --- components/table/Table.tsx | 5 +- .../__tests__/__snapshots__/demo.test.js.snap | 47 +++++++++++++ components/table/demo/index.vue | 3 + components/table/demo/responsive.vue | 70 +++++++++++++++++++ 4 files changed, 123 insertions(+), 2 deletions(-) create mode 100644 components/table/demo/responsive.vue diff --git a/components/table/Table.tsx b/components/table/Table.tsx index 8921a8494..4619d5472 100644 --- a/components/table/Table.tsx +++ b/components/table/Table.tsx @@ -262,8 +262,9 @@ const InteralTable = defineComponent< const screens = useBreakpoint(); const mergedColumns = computed(() => { - const matched = new Set(Object.keys(screens).filter((m: Breakpoint) => screens[m])); - + const matched = new Set( + Object.keys(screens.value).filter((m: Breakpoint) => screens.value[m]), + ); return props.columns.filter( (c: ColumnType) => !c.responsive || c.responsive.some((r: Breakpoint) => matched.has(r)), diff --git a/components/table/__tests__/__snapshots__/demo.test.js.snap b/components/table/__tests__/__snapshots__/demo.test.js.snap index 2fd191d93..ef7da1e35 100644 --- a/components/table/__tests__/__snapshots__/demo.test.js.snap +++ b/components/table/__tests__/__snapshots__/demo.test.js.snap @@ -4160,6 +4160,53 @@ exports[`renders ./components/table/demo/resizable-column.vue correctly 1`] = ` `; +exports[`renders ./components/table/demo/responsive.vue correctly 1`] = ` +
+
+ +
+
+ +
+
+ + + + + + + + + + + + + + + +
+ Name (all screens) + +
+ John Brown + +
+
+
+ +
+
    + +
  • +
  • 1
  • +
  • + +
+
+
+
+`; + exports[`renders ./components/table/demo/row-selection.vue correctly 1`] = `
diff --git a/components/table/demo/index.vue b/components/table/demo/index.vue index 6947b1613..c72af87ae 100644 --- a/components/table/demo/index.vue +++ b/components/table/demo/index.vue @@ -26,6 +26,7 @@ + @@ -61,6 +62,7 @@ import Summary from './summary.vue'; import Sticky from './sticky.vue'; import ResizableColumn from './resizable-column.vue'; import bigData from './big-data.vue'; +import Responsive from './responsive.vue'; import CN from '../index.zh-CN.md'; import US from '../index.en-US.md'; import { defineComponent } from 'vue'; @@ -97,6 +99,7 @@ export default defineComponent({ Sticky, ResizableColumn, bigData, + Responsive, }, }); diff --git a/components/table/demo/responsive.vue b/components/table/demo/responsive.vue new file mode 100644 index 000000000..240e9b538 --- /dev/null +++ b/components/table/demo/responsive.vue @@ -0,0 +1,70 @@ + +--- +order: 30 +title: + en-US: Responsive + zh-CN: 响应式 +--- + +## zh-CN + +响应式配置列的展示。 + +## en-US + +Responsive columns. + + + +