From d3f4b936fbbe8e4c3eb6fca6f3cbc34e02eb09a0 Mon Sep 17 00:00:00 2001 From: dap <15891557205@163.com> Date: Mon, 30 Jun 2025 19:32:23 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20withDefaultPlaceholder=E4=B8=ADplacehold?= =?UTF-8?q?er=20=E5=9C=A8keepalive=20&=20=E8=AF=AD=E8=A8=80=E5=88=87?= =?UTF-8?q?=E6=8D=A2=20&=20tab=E5=88=87=E6=8D=A2=20=E6=98=BE=E7=A4=BA?= =?UTF-8?q?=E4=B8=8D=E5=8F=98=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 1 + apps/web-antd/src/adapter/component/index.ts | 14 +++++++++----- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c36b1a42..cb359556 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ **BUG FIX** - 菜单管理 路由地址的必填项不生效 +- withDefaultPlaceholder中placeholder 在keepalive & 语言切换 & tab切换 显示不变的问题 **REFACTOR** diff --git a/apps/web-antd/src/adapter/component/index.ts b/apps/web-antd/src/adapter/component/index.ts index 61956b3f..2b3c1522 100644 --- a/apps/web-antd/src/adapter/component/index.ts +++ b/apps/web-antd/src/adapter/component/index.ts @@ -9,6 +9,7 @@ import type { BaseFormComponentType } from '@vben/common-ui'; import type { Recordable } from '@vben/types'; import { + computed, defineAsyncComponent, defineComponent, getCurrentInstance, @@ -93,10 +94,13 @@ const withDefaultPlaceholder = ( name: component.name, inheritAttrs: false, setup: (props: any, { attrs, expose, slots }) => { - const placeholder = - props?.placeholder || - attrs?.placeholder || - $t(`ui.placeholder.${type}`); + // 改为placeholder 解决在keepalive & 语言切换 & tab切换 显示不变的问题 + const computedPlaceholder = computed( + () => + props?.placeholder || + attrs?.placeholder || + $t(`ui.placeholder.${type}`), + ); // 透传组件暴露的方法 const innerRef = ref(); @@ -115,7 +119,7 @@ const withDefaultPlaceholder = ( component, { ...componentProps, - placeholder, + placeholder: computedPlaceholder.value, ...props, ...attrs, ref: innerRef,