From 2e064604c1ffe845f4fba8e7fe9a682bf1afcf11 Mon Sep 17 00:00:00 2001 From: dap <15891557205@163.com> Date: Fri, 14 Mar 2025 16:09:37 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20`withDefaultPlaceholder`=E4=B8=AD?= =?UTF-8?q?=E5=B0=86`placeholder`=E4=BF=AE=E6=94=B9=E4=B8=BAcomputed,=20?= =?UTF-8?q?=E8=A7=A3=E5=86=B3=E5=90=8E=E7=BB=AD=E4=BD=BF=E7=94=A8`updateSc?= =?UTF-8?q?hema`=E6=97=A0=E6=B3=95=E6=AD=A3=E5=B8=B8=E6=9B=B4=E6=96=B0?= =?UTF-8?q?=E6=98=BE=E7=A4=BAplaceholder(=E5=93=8D=E5=BA=94=E5=BC=8F?= =?UTF-8?q?=E9=97=AE=E9=A2=98)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 6 ++++++ apps/web-antd/package.json | 2 +- apps/web-antd/src/adapter/component/index.ts | 22 ++++++++++++++------ 3 files changed, 23 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c4fe17ae..e074de7a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +# 1.2.3 + +**BUG FIX** + +- `withDefaultPlaceholder`中将`placeholder`修改为computed, 解决后续使用`updateSchema`无法正常更新显示placeholder(响应式问题) + # 1.2.2 **FEATURES** diff --git a/apps/web-antd/package.json b/apps/web-antd/package.json index 49063a18..fdfda3d9 100644 --- a/apps/web-antd/package.json +++ b/apps/web-antd/package.json @@ -1,6 +1,6 @@ { "name": "@vben/web-antd", - "version": "1.2.2", + "version": "1.2.3", "homepage": "https://vben.pro", "bugs": "https://github.com/vbenjs/vue-vben-admin/issues", "repository": { diff --git a/apps/web-antd/src/adapter/component/index.ts b/apps/web-antd/src/adapter/component/index.ts index 10ab89d5..c61e9b48 100644 --- a/apps/web-antd/src/adapter/component/index.ts +++ b/apps/web-antd/src/adapter/component/index.ts @@ -8,7 +8,7 @@ import type { Component } from 'vue'; import type { BaseFormComponentType } from '@vben/common-ui'; import type { Recordable } from '@vben/types'; -import { defineComponent, getCurrentInstance, h, ref } from 'vue'; +import { computed, defineComponent, getCurrentInstance, h, ref } from 'vue'; import { ApiComponent, globalShareState, IconPicker } from '@vben/common-ui'; import { $t } from '@vben/locales'; @@ -49,10 +49,16 @@ const withDefaultPlaceholder = ( inheritAttrs: false, name: component.name, setup: (props: any, { attrs, expose, slots }) => { - const placeholder = - props?.placeholder || - attrs?.placeholder || - $t(`ui.placeholder.${type}`); + /** + * 需要使用computed 否则后续updateSchema更新的placeholder无法显示(响应式问题) + */ + const placeholder = computed( + () => + props?.placeholder || + attrs?.placeholder || + $t(`ui.placeholder.${type}`), + ); + // 透传组件暴露的方法 const innerRef = ref(); const publicApi: Recordable = {}; @@ -66,7 +72,11 @@ const withDefaultPlaceholder = ( } }); return () => - h(component, { ...props, ...attrs, placeholder, ref: innerRef }, slots); + h( + component, + { ...props, ...attrs, placeholder: placeholder.value, ref: innerRef }, + slots, + ); }, }); };