From 50b15ab0065f974c49abfd21bd672782f71efbfe Mon Sep 17 00:00:00 2001 From: codelo <39475510+codelo-99@users.noreply.github.com> Date: Thu, 22 May 2025 18:08:25 +0800 Subject: [PATCH] fix Upload.tsx button visible MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修复 Upload组件 listType="picture-card" showUploadList="false" disabled 上传按钮一直存在的bug --- components/upload/Upload.tsx | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/components/upload/Upload.tsx b/components/upload/Upload.tsx index 577c6ee874..07b2dfec32 100644 --- a/components/upload/Upload.tsx +++ b/components/upload/Upload.tsx @@ -8,7 +8,7 @@ import { useLocaleReceiver } from '../locale-provider/LocaleReceiver'; import defaultLocale from '../locale/en_US'; import type { CSSProperties } from 'vue'; import { computed, defineComponent, onMounted, ref, toRef } from 'vue'; -import { flattenChildren, initDefaultProps } from '../_util/props-util'; +import { filterEmpty, flattenChildren, initDefaultProps } from '../_util/props-util'; import useMergedState from '../_util/hooks/useMergedState'; import devWarning from '../vc-util/devWarning'; import useConfigInject from '../config-provider/hooks/useConfigInject'; @@ -299,6 +299,9 @@ export default defineComponent({ defaultLocale.Upload, computed(() => props.locale), ); + const HackSlot = (_, { slots }) => { + return filterEmpty(slots.default?.())[0]; + }; const renderUploadList = (button?: () => VueNode, buttonVisible?: boolean) => { const { removeIcon, @@ -340,7 +343,13 @@ export default defineComponent({ v-slots={{ ...slots }} /> ) : ( - button?.() + button ? ( + + ) : null ); }; return () => {