Skip to content

Commit

Permalink
fix(dropdownmenu): 改变label定义标题不起效 (#1123)
Browse files Browse the repository at this point in the history
  • Loading branch information
LoopZhou authored Oct 11, 2023
1 parent ab6e2a0 commit 08fe605
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/dropdown-menu/dropdown-menu.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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']) || '');
Expand All @@ -81,7 +83,7 @@ export default defineComponent({
};
}
return {
label: menuTitles.value[index].label,
label: label || menuTitles.value[index].label,
disabled: disabled !== undefined && disabled !== false,
};
}),
Expand Down

0 comments on commit 08fe605

Please sign in to comment.