Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(dropdownmenu): 改变label定义标题不起效 #1123

Merged
merged 1 commit into from
Oct 11, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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