mirror of
https://gitee.com/baidu/amis.git
synced 2024-12-05 05:18:34 +08:00
Nav 支持 onSelect 事件
This commit is contained in:
parent
12e05f05d2
commit
c82bc27820
@ -10,6 +10,7 @@ import {resolveVariable, isPureVariable} from '../utils/tpl-builtin';
|
||||
import {isApiOutdated, isEffectiveApi} from '../utils/api';
|
||||
import {ScopedContext, IScopedContext} from '../Scoped';
|
||||
import {Api} from '../types';
|
||||
import {ClassNamesFn, themeable} from '../theme';
|
||||
|
||||
export interface Link {
|
||||
className?: string;
|
||||
@ -30,6 +31,8 @@ export interface NavigationState {
|
||||
}
|
||||
|
||||
export interface NavigationProps extends RendererProps {
|
||||
classnames: ClassNamesFn;
|
||||
classPrefix: string;
|
||||
className?: string;
|
||||
stacked?: boolean;
|
||||
links?: Links;
|
||||
@ -37,7 +40,7 @@ export interface NavigationProps extends RendererProps {
|
||||
onSelect?: (item: Link) => any;
|
||||
}
|
||||
|
||||
export default class Navigation extends React.Component<
|
||||
export class Navigation extends React.Component<
|
||||
NavigationProps,
|
||||
NavigationState
|
||||
> {
|
||||
@ -228,17 +231,17 @@ export default class Navigation extends React.Component<
|
||||
icon?: string;
|
||||
children?: Links;
|
||||
}) {
|
||||
if (!link.to) {
|
||||
link.children && link.children.length && this.toggleLink(link);
|
||||
return;
|
||||
}
|
||||
|
||||
const {env, data, onSelect} = this.props;
|
||||
|
||||
if (onSelect && onSelect(link) === false) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!link.to) {
|
||||
link.children && link.children.length && this.toggleLink(link);
|
||||
return;
|
||||
}
|
||||
|
||||
env && env.jumpTo(filter(link.to as string, data), link as any);
|
||||
}
|
||||
|
||||
@ -307,6 +310,8 @@ export default class Navigation extends React.Component<
|
||||
}
|
||||
}
|
||||
|
||||
export default themeable(Navigation);
|
||||
|
||||
@Renderer({
|
||||
test: /(^|\/)(?:nav|navigation)$/,
|
||||
name: 'nav'
|
||||
|
Loading…
Reference in New Issue
Block a user