fix: withDefaultPlaceholder中placeholder 在keepalive & 语言切换 & tab切换 显示不变的问题

master
dap 6 months ago
parent fb64d9f87a
commit d3f4b936fb

@ -8,6 +8,7 @@
**BUG FIX**
- 菜单管理 路由地址的必填项不生效
- withDefaultPlaceholder中placeholder 在keepalive & 语言切换 & tab切换 显示不变的问题
**REFACTOR**

@ -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 = <T extends Component>(
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 = <T extends Component>(
component,
{
...componentProps,
placeholder,
placeholder: computedPlaceholder.value,
...props,
...attrs,
ref: innerRef,

Loading…
Cancel
Save