diff --git a/src/dropdown/_example/slot.vue b/src/dropdown/_example/slot.vue
index e88fca6942..0144989470 100644
--- a/src/dropdown/_example/slot.vue
+++ b/src/dropdown/_example/slot.vue
@@ -59,7 +59,7 @@
- 操作二
+ 操作二
操作三
@@ -73,7 +73,7 @@ import { MessagePlugin } from 'tdesign-vue-next';
const clickHandler = (data) => {
console.log(data, 'data');
- if (data.value !== 212) MessagePlugin.success(`选中【${data.content}】`);
+ if (data.value !== 212) MessagePlugin.success(`选中【${data.value}】`);
};
const handleClick = () => {
MessagePlugin.success(`点击 操作2-1-2`);
diff --git a/src/dropdown/dropdown-menu.tsx b/src/dropdown/dropdown-menu.tsx
index aa899d43c0..37bbdf1792 100644
--- a/src/dropdown/dropdown-menu.tsx
+++ b/src/dropdown/dropdown-menu.tsx
@@ -38,7 +38,8 @@ export default defineComponent({
renderContent = (
{
.map((item) => {
const groupChildren = item.children?.default?.();
- const contentIdx = groupChildren?.findIndex?.(
- (v: VNode) => typeof v.children === 'string' && (v.type as { description: string }).description !== 'Comment',
+ // 当前节点的渲染内容
+ const contentCtx = groupChildren?.filter?.(
+ (v: VNode) => !['TDropdownMenu', 'TDropdownItem'].includes((v.type as { name: string })?.name),
);
- const childrenContent = groupChildren?.filter?.(
+ // 嵌套菜单的节点
+ const childrenCtx = groupChildren?.filter?.(
(v: VNode) =>
typeof v.children !== 'string' &&
['TDropdownMenu', 'TDropdownItem'].includes((v.type as { name: string })?.name),
);
+
return {
...item.props,
- content: groupChildren?.[contentIdx]?.children || groupChildren,
- children: childrenContent?.length > 0 ? getOptionsFromChildren(childrenContent) : null,
+ content: contentCtx || groupChildren,
+ children: childrenCtx?.length > 0 ? getOptionsFromChildren(childrenCtx) : null,
};
})
.filter((v) => !!v.content);