tab需要点击时再加载”

This commit is contained in:
catchonme 2019-08-13 14:08:14 +08:00
parent 0761bf0b7e
commit 2892e63c5f

View File

@ -30,6 +30,8 @@ export interface TabsProps extends RendererProps {
contentClassName: string; contentClassName: string;
handleSelect?: Function; handleSelect?: Function;
location?: any; location?: any;
mountOnEnter?: boolean;
unmountOnExit?: boolean;
tabs?: Array<TabProps>; tabs?: Array<TabProps>;
tabRender?: (tab: TabProps, props?: TabsProps) => JSX.Element; tabRender?: (tab: TabProps, props?: TabsProps) => JSX.Element;
} }
@ -203,6 +205,8 @@ export default class Tabs extends React.Component<TabsProps, TabsState> {
data, data,
mode: dMode, mode: dMode,
tabsMode, tabsMode,
mountOnEnter,
unmountOnExit
} = this.props; } = this.props;
if (!Array.isArray(tabs)) { if (!Array.isArray(tabs)) {
@ -232,6 +236,16 @@ export default class Tabs extends React.Component<TabsProps, TabsState> {
{...tab} {...tab}
key={index} key={index}
eventKey={tab.hash || index} eventKey={tab.hash || index}
mountOnEnter={mountOnEnter}
unmountOnExit={
typeof tab.reload === 'boolean'
? tab.reload
: (
typeof tab.unmountOnExit === 'boolean'
? tab.unmountOnExit
: unmountOnExit
)
}
> >
{tabRender {tabRender
? tabRender(tab, this.props) ? tabRender(tab, this.props)