From 3ed25749254756cae4208e05f26e4fd3de520849 Mon Sep 17 00:00:00 2001 From: loopzhou <363415642@qq.com> Date: Tue, 10 Oct 2023 17:08:48 +0800 Subject: [PATCH] =?UTF-8?q?fix(dropdownmenu):=20=E6=94=B9=E5=8F=98label?= =?UTF-8?q?=E5=AE=9A=E4=B9=89=E6=A0=87=E9=A2=98=E4=B8=8D=E8=B5=B7=E6=95=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/dropdown-menu/dropdown-menu.vue | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/dropdown-menu/dropdown-menu.vue b/src/dropdown-menu/dropdown-menu.vue index f674d0870..b410efc24 100644 --- a/src/dropdown-menu/dropdown-menu.vue +++ b/src/dropdown-menu/dropdown-menu.vue @@ -66,8 +66,10 @@ export default defineComponent({ // 通过 slots.default 子成员,计算标题栏选项 const menuTitles = computed(() => menuItems.value.map((item: any, index: number) => { - const { keys, label, value, disabled, options } = item.props; - const target = options?.find((item: any) => item[keys?.value ?? 'value'] === value); + const { keys, label, value, modelValue, defaultValue, disabled, options } = item.props; + const currentValue = value || modelValue || defaultValue; + const target = options?.find((item: any) => item[keys?.value ?? 'value'] === currentValue); + if (state.itemsLabel.length < index + 1) { if (!label) { state.itemsLabel.push((target && target[keys?.label ?? 'label']) || ''); @@ -81,7 +83,7 @@ export default defineComponent({ }; } return { - label: menuTitles.value[index].label, + label: label || menuTitles.value[index].label, disabled: disabled !== undefined && disabled !== false, }; }),