Commit 2c536976e8f287794acae61b6df7fe4033a98ffa

Authored by GauharChan
Committed by GitHub
1 parent c2e2ca9b

feat(function): add table bodyCell slot for antdv3.x; and fix #1705 (#1991)

src/components/Table/src/BasicTable.vue
... ... @@ -28,6 +28,10 @@
28 28 <template #headerCell="{ column }">
29 29 <HeaderCell :column="column" />
30 30 </template>
  31 + <!-- 增加对antdv3.x兼容 -->
  32 + <template #bodyCell="data">
  33 + <slot name="bodyCell" v-bind="data || {}"></slot>
  34 + </template>
31 35 <!-- <template #[`header-${column.dataIndex}`] v-for="(column, index) in columns" :key="index">-->
32 36 <!-- <HeaderCell :column="column" />-->
33 37 <!-- </template>-->
... ...
src/views/demo/table/CustomerCell.vue
1 1 <template>
2 2 <div class="p-4">
3 3 <BasicTable @register="registerTable">
4   - <template #id="{ record }"> ID: {{ record.id }} </template>
5   - <template #no="{ record }">
6   - <Tag color="green">
7   - {{ record.no }}
8   - </Tag>
9   - </template>
10   - <template #avatar="{ record }">
11   - <Avatar :size="60" :src="record.avatar" />
12   - </template>
13   - <template #img="{ text }">
14   - <TableImg :size="60" :simpleShow="true" :imgList="text" />
15   - </template>
16   - <template #imgs="{ text }"> <TableImg :size="60" :imgList="text" /> </template>
  4 + <template #bodyCell="{ column, record, text }">
  5 + <template v-if="column.key === 'id'"> ID: {{ record.id }} </template>
  6 + <template v-if="column.key === 'no'">
  7 + <Tag color="green">
  8 + {{ record.no }}
  9 + </Tag>
  10 + </template>
  11 + <template v-if="column.key === 'avatar'">
  12 + <Avatar :size="60" :src="record.avatar" />
  13 + </template>
  14 + <template v-if="column.key === 'imgArr'">
  15 + <TableImg :size="60" :simpleShow="true" :imgList="text" />
  16 + </template>
  17 + <template v-if="column.key === 'imgs'"> <TableImg :size="60" :imgList="text" /> </template>
17 18  
18   - <template #category="{ record }">
19   - <Tag color="green">
20   - {{ record.no }}
21   - </Tag>
  19 + <template v-if="column.key === 'category'">
  20 + <Tag color="green">
  21 + {{ record.no }}
  22 + </Tag>
  23 + </template>
22 24 </template>
23 25 </BasicTable>
24 26 </div>
... ...