| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 | import React from 'react';import { Menu, Icon } from 'antd';import '../leftTab.less';const SubMenu = Menu.SubMenu;const MenuItemGroup = Menu.ItemGroup;const LeftTab = React.createClass({    getInitialState() {        return {            current: 'star',            subKey: 'sub1',            keyList: [                { key: 'sub1', value: ['star','lecture'] },            ]        };    },    handleClick(e) {        this.props.handlekey(e.key);        this.setState({            current: e.key,        });    },    componentWillMount() {        const _me = this;        if (window.location.hash) {            let theKey = window.location.hash.substr(1);            this.state.keyList.map(function (item1) {                item1.value.map(function (item2) {                    if (theKey == item2) {                        _me.state.subKey = item1.key                    };                });            });            this.state.current = theKey;        };    },    render() {        return (            <Menu onClick={this.handleClick}                selectedKeys={[this.state.current]}                defaultOpenKeys={[this.state.subKey]}                mode="vertical"                className="account-left"                mode="inline" >                <SubMenu key="sub1" title={<span>大咖说</span>}>                    <Menu.Item key="star">                        科技明星                    </Menu.Item>                    <Menu.Item key="lecture">                        科技讲堂                    </Menu.Item>                </SubMenu>            </Menu>        );    }});export default LeftTab;
 |