From 623ffb13e37b129c45c1738fffcded48cd1b3c06 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E6=98=B1=E8=BE=BE?= Date: Tue, 27 May 2025 15:03:41 +0800 Subject: [PATCH] =?UTF-8?q?feat(Table):=20=E5=A2=9E=E5=8A=A0=E8=A1=A8?= =?UTF-8?q?=E6=A0=BC=E5=88=97=E8=87=AA=E5=AE=9A=E4=B9=89=E6=B8=B2=E6=9F=93?= =?UTF-8?q?=E5=8A=9F=E8=83=BD=E5=B9=B6=E4=BC=98=E5=8C=96=E9=A6=96=E9=A1=B5?= =?UTF-8?q?=E6=8E=A8=E8=8D=90=E7=BB=84=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 在 YlTable 组件中添加 RenderSlot 组件,实现自定义渲染功能 - 在 HomeRecommend 组件中使用自定义渲染功能,根据数据动态显示颜色 - 优化 HomeRecommend组件的代码结构 --- src/components/YlTable/Index.vue | 29 +++ src/hooks/chart/usePieChart.ts | 2 - src/views/Home/Index.vue | 202 ++++++++--------- .../Home/components/HomeRecommend/Index.vue | 210 +++++++++--------- 4 files changed, 240 insertions(+), 203 deletions(-) diff --git a/src/components/YlTable/Index.vue b/src/components/YlTable/Index.vue index 4809cd0..f8083d6 100644 --- a/src/components/YlTable/Index.vue +++ b/src/components/YlTable/Index.vue @@ -106,6 +106,26 @@ function tooptipFormatter(data: { row: any; column: any; cellValue: any }): VNod content: data }); } + +// render +const RenderSlot = { + functional: true, + props: { + row: Object, + render: Function, + index: Number, + column: { + type: Object, + default: null + } + }, + setup(props) { + return () => { + const { row, index, column } = props; + return props.render(h, { row, index, column }); + }; + } +};