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

This commit is contained in:
GauharChan 2022-06-24 04:36:20 +08:00 committed by GitHub
parent c2e2ca9bed
commit 2c536976e8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 23 additions and 17 deletions

View File

@ -28,6 +28,10 @@
<template #headerCell="{ column }">
<HeaderCell :column="column" />
</template>
<!-- 增加对antdv3.x兼容 -->
<template #bodyCell="data">
<slot name="bodyCell" v-bind="data || {}"></slot>
</template>
<!-- <template #[`header-${column.dataIndex}`] v-for="(column, index) in columns" :key="index">-->
<!-- <HeaderCell :column="column" />-->
<!-- </template>-->

View File

@ -1,24 +1,26 @@
<template>
<div class="p-4">
<BasicTable @register="registerTable">
<template #id="{ record }"> ID: {{ record.id }} </template>
<template #no="{ record }">
<Tag color="green">
{{ record.no }}
</Tag>
</template>
<template #avatar="{ record }">
<Avatar :size="60" :src="record.avatar" />
</template>
<template #img="{ text }">
<TableImg :size="60" :simpleShow="true" :imgList="text" />
</template>
<template #imgs="{ text }"> <TableImg :size="60" :imgList="text" /> </template>
<template #bodyCell="{ column, record, text }">
<template v-if="column.key === 'id'"> ID: {{ record.id }} </template>
<template v-if="column.key === 'no'">
<Tag color="green">
{{ record.no }}
</Tag>
</template>
<template v-if="column.key === 'avatar'">
<Avatar :size="60" :src="record.avatar" />
</template>
<template v-if="column.key === 'imgArr'">
<TableImg :size="60" :simpleShow="true" :imgList="text" />
</template>
<template v-if="column.key === 'imgs'"> <TableImg :size="60" :imgList="text" /> </template>
<template #category="{ record }">
<Tag color="green">
{{ record.no }}
</Tag>
<template v-if="column.key === 'category'">
<Tag color="green">
{{ record.no }}
</Tag>
</template>
</template>
</BasicTable>
</div>