基于React的Tab组件
Tabs
renderHeader = () => { return React.Children.map( this.props.children , (element,index) => { const activeStyle = element.key === this.state.activeKey ? "activeTitle" : null; return ( { this.setState({ activeKey: element.key }) }} className={classnames("title", activeStyle)} > {element.props.title} ) }) } renderContent = () => { return React.Children.map( this.props.children , (element,index) => { if (element.key === this.state.activeKey) { return ( ) } }) } render() { return ( ) }
TabPane
render() { return ( ) }
调用
render() { return ( ) }