Skip to content

Commit

Permalink
feat(menu-item): click事件参数增加value (#2689)
Browse files Browse the repository at this point in the history
fix #2621
  • Loading branch information
dexterBo committed Aug 15, 2023
1 parent 81b4701 commit 24b6ccc
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/menu/menu-item.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ export default defineComponent({
e.stopPropagation();
if (props.disabled) return;
menu.select(props.value);
ctx.emit('click', { e });
props.onClick?.({ e });
ctx.emit('click', { e, value: props.value });
props.onClick?.({ e, value: props.value });

if (props.to || (props.routerLink && props.href)) {
const router = props.router || (ctx.root as Record<string, any>).$router;
Expand Down
4 changes: 2 additions & 2 deletions src/menu/menu.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,13 @@ router | Object | - | 路由对象。如果项目存在 Router,则默认使用
target | String | - | 链接或路由跳转方式。可选项:_blank/_self/_parent/_top | N
to | String / Object | - | 路由跳转目标,当且仅当 Router 存在时,该 API 有效。TS 类型:`MenuRoute` `interface MenuRoute { path?: string; name?: string; hash?: string; query?: MenuQueryData; params?: MenuQueryData }` `type MenuQueryData = { [key: string]: string \| string[] }`[详细类型定义](https://github.com/Tencent/tdesign-vue/tree/develop/src/menu/type.ts) | N
value | String / Number | - | 菜单项唯一标识。TS 类型:`MenuValue` | N
onClick | Function | | TS 类型:`(context: { e: MouseEvent }) => void`<br/>点击时触发 | N
onClick | Function | | TS 类型:`(context: { e: MouseEvent, value: MenuValue }) => void`<br/>点击时触发 | N

### MenuItem Events

名称 | 参数 | 描述
-- | -- | --
click | `(context: { e: MouseEvent })` | 点击时触发
click | `(context: { e: MouseEvent, value: MenuValue })` | 点击时触发

### MenuGroup Props

Expand Down
2 changes: 1 addition & 1 deletion src/menu/type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ export interface TdMenuItemProps {
/**
* 点击时触发
*/
onClick?: (context: { e: MouseEvent }) => void;
onClick?: (context: { e: MouseEvent; value: MenuValue }) => void;
}

export interface TdMenuGroupProps {
Expand Down

0 comments on commit 24b6ccc

Please sign in to comment.