fix: update bodyCell headerCell

pull/4639/head
tangjinzhou 2021-09-06 19:27:41 +08:00
parent 562d86f189
commit c45b93bc8e
3 changed files with 9 additions and 3 deletions

View File

@ -623,7 +623,6 @@ const Table = defineComponent<TableProps>({
setup(_props, { attrs, slots }) {
return () => {
const columns = (attrs.columns || convertChildrenToColumns(slots.default?.())) as ColumnsType;
console.log('slots', slots);
return (
<InteralTable
{...attrs}

View File

@ -1,3 +1,4 @@
import devWarning from '../../vc-util/devWarning';
import type { Ref } from 'vue';
import { ContextSlots } from '../context';
import type { TransformColumns, ColumnTitleProps, ColumnsType } from '../interface';
@ -13,6 +14,12 @@ function fillTitle<RecordType>(
const cloneColumn = { ...column };
const { slots = {} } = cloneColumn;
devWarning(
!('slots' in cloneColumn),
'Table',
'`column.slots` is deprecated. Please use `v-slot:headerCell` `v-slot:bodyCell` instead.',
);
Object.keys(slots).forEach(key => {
const name = slots[key];
if (cloneColumn[key] === undefined && $slots[name]) {

View File

@ -119,7 +119,7 @@ export default defineComponent<CellProps>({
const children = slots.default?.();
if (validateValue(children) || cellType === 'header') {
childNode = children;
if (cellType === 'header' && contextSlots.value.headerCell) {
if (cellType === 'header' && contextSlots.value.headerCell && !column.slots?.title) {
childNode = contextSlots.value.headerCell({ title: column.title, index, column });
}
} else {
@ -138,7 +138,7 @@ export default defineComponent<CellProps>({
}
}
if (cellType === 'body' && contextSlots.value.bodyCell) {
if (cellType === 'body' && contextSlots.value.bodyCell && !column.slots?.customRender) {
childNode = contextSlots.value.bodyCell({ text: value, value, record, index, column });
}
}