Nav 支持 onSelect 事件

This commit is contained in:
2betop 2020-04-09 15:58:29 +08:00
parent 5557c4e226
commit 085ef85c6a

View File

@ -34,6 +34,7 @@ export interface NavigationProps extends RendererProps {
stacked?: boolean; stacked?: boolean;
links?: Links; links?: Links;
source?: Api; source?: Api;
onSelect?: (item: Link) => any;
} }
export default class Navigation extends React.Component< export default class Navigation extends React.Component<
@ -232,7 +233,11 @@ export default class Navigation extends React.Component<
return; return;
} }
const {env, data} = this.props; const {env, data, onSelect} = this.props;
if (onSelect && onSelect(link) === false) {
return;
}
env && env.jumpTo(filter(link.to as string, data), link as any); env && env.jumpTo(filter(link.to as string, data), link as any);
} }