diff --git a/components/table/components/cell.tsx b/components/table/components/cell.tsx index 436c1515..b9765512 100644 --- a/components/table/components/cell.tsx +++ b/components/table/components/cell.tsx @@ -2,6 +2,7 @@ import { defineComponent, Fragment, inject, + isVNode, type PropType, type ExtractPropTypes, type ComponentObjectPropsOptions, @@ -88,7 +89,15 @@ export default defineComponent({ {column.slots.default(props)} ); } - const result = column?.props?.formatter?.(props) ?? cellValue; + const formatterResult = column?.props?.formatter?.(props); + if (isVNode(formatterResult)) { + return ( + + {formatterResult} + + ); + } + const result = formatterResult ?? cellValue; Object.assign(ellipsisProps, { content: result }); return hasEllipsis ? ( diff --git a/docs/.vitepress/components/table/customContent.vue b/docs/.vitepress/components/table/customContent.vue index c1b96fa9..7b88ba27 100644 --- a/docs/.vitepress/components/table/customContent.vue +++ b/docs/.vitepress/components/table/customContent.vue @@ -63,14 +63,24 @@ export default defineComponent({ }, { prop: 'name', - label: '姓名', + label: '姓名1', render: ({ row }) => { return h(FTag, {}, () => row.name); }, }, + { + prop: 'name', + label: '姓名2', + formatter: ({ row }) => { + return h(FTag, {}, () => row.name); + }, + }, { prop: 'address', label: '地址', + formatter: ({ row }) => { + return row.address; + }, }, { prop: 'action',