From 79a597685043741541a04546abf460d4c75b5845 Mon Sep 17 00:00:00 2001 From: Dexter <52393227+dexterBo@users.noreply.github.com> Date: Tue, 15 Aug 2023 11:37:55 +0800 Subject: [PATCH] =?UTF-8?q?feat(menu-item):=20onClick=E4=BA=8B=E4=BB=B6?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0value=E8=BF=94=E5=9B=9E=E5=80=BC=20(#2441)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat(menu-item): onClick事件增加value返回值 fix #2621 * docs(menu): menu-item 组件文档修改 --- src/menu/MenuItem.tsx | 2 +- src/menu/menu.md | 2 +- src/menu/type.ts | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/menu/MenuItem.tsx b/src/menu/MenuItem.tsx index 890791c17..652da9656 100644 --- a/src/menu/MenuItem.tsx +++ b/src/menu/MenuItem.tsx @@ -35,7 +35,7 @@ const MenuItem: FC = (props) => { e.stopPropagation(); if (disabled) return; - onClick && onClick({ e }); + onClick && onClick({ e, value }); if (value !== active) onChange(value); setState({ active: value }); }; diff --git a/src/menu/menu.md b/src/menu/menu.md index ed21bfdd7..aa53e1678 100644 --- a/src/menu/menu.md +++ b/src/menu/menu.md @@ -65,7 +65,7 @@ href | String | - | 跳转链接 | N icon | TElement | - | 图标。TS 类型:`TNode`。[通用类型定义](https://github.com/Tencent/tdesign-react/blob/develop/src/common.ts) | N target | String | - | 链接或路由跳转方式。可选项:_blank/_self/_parent/_top | N value | String / Number | - | 菜单项唯一标识。TS 类型:`MenuValue` | N -onClick | Function | | TS 类型:`(context: { e: MouseEvent }) => void`
点击时触发 | N +onClick | Function | | TS 类型:`(context: { e: MouseEvent, value: MenuValue }) => void`
点击时触发 | N ### MenuGroup Props diff --git a/src/menu/type.ts b/src/menu/type.ts index 72103711b..65e03037b 100644 --- a/src/menu/type.ts +++ b/src/menu/type.ts @@ -177,7 +177,7 @@ export interface TdMenuItemProps { /** * 点击时触发 */ - onClick?: (context: { e: MouseEvent }) => void; + onClick?: (context: { e: MouseEvent; value: MenuValue }) => void; } export interface TdMenuGroupProps {