yapi/client/components/Subnav/Subnav.js

40 lines
904 B
JavaScript
Raw Normal View History

2017-08-08 15:24:26 +08:00
import './Subnav.scss';
import React, { Component } from 'react';
2017-08-08 16:21:32 +08:00
import { Link } from 'react-router-dom';
2017-08-08 15:24:26 +08:00
import PropTypes from 'prop-types';
import { Menu } from 'antd';
class Subnav extends Component {
constructor(props) {
super(props)
}
2017-08-08 16:21:32 +08:00
2017-08-08 15:24:26 +08:00
static propTypes = {
2017-08-08 16:21:32 +08:00
data: PropTypes.array,
default: PropTypes.string
2017-08-08 15:24:26 +08:00
}
2017-08-08 16:21:32 +08:00
2017-08-08 15:24:26 +08:00
render () {
return (
<div className="m-subnav">
<Menu
onClick={this.handleClick}
2017-08-08 16:21:32 +08:00
defaultSelectedKeys={[this.props.default]}
2017-08-08 15:24:26 +08:00
mode="horizontal"
className="g-row m-subnav-menu"
>
{this.props.data.map((item, index) => {
return (
<Menu.Item className="item" key={item.name}>
2017-08-08 16:21:32 +08:00
<Link to={item.path}>{this.props.data[index].name}</Link>
2017-08-08 15:24:26 +08:00
</Menu.Item>
)
})}
</Menu>
</div>
)
}
}
2017-08-08 16:21:32 +08:00
export default Subnav;