yapi/client/components/Breadcrumb/Breadcrumb.js

39 lines
974 B
JavaScript
Raw Normal View History

2017-07-28 17:30:56 +08:00
import './Breadcrumb.scss';
2017-08-28 17:24:17 +08:00
import { withRouter } from 'react-router-dom';
2017-07-28 17:30:56 +08:00
import { Breadcrumb } from 'antd';
2017-07-30 15:06:03 +08:00
import PropTypes from 'prop-types'
2017-07-28 17:30:56 +08:00
import React, { Component } from 'react';
2017-08-28 17:24:17 +08:00
import { connect } from 'react-redux';
import { Link } from 'react-router-dom'
2017-07-28 21:16:47 +08:00
2017-08-28 17:24:17 +08:00
@connect(
state => {
return {
breadcrumb: state.user.breadcrumb
}
}
)
2017-07-28 17:30:56 +08:00
@withRouter
export default class BreadcrumbNavigation extends Component {
constructor(props) {
super(props);
2017-07-28 21:16:47 +08:00
}
2017-07-30 15:06:03 +08:00
static propTypes = {
2017-08-28 17:24:17 +08:00
breadcrumb: PropTypes.array
2017-07-30 15:06:03 +08:00
}
2017-08-28 17:24:17 +08:00
render () {
const getItem = this.props.breadcrumb.map((item, index) => {
2017-08-28 18:12:13 +08:00
if (item.href) {
2017-08-28 17:24:17 +08:00
return (<Breadcrumb.Item key={index}><Link to={item.href}>{item.name}</Link></Breadcrumb.Item>);
} else {
return (<Breadcrumb.Item key={index}>{item.name}</Breadcrumb.Item>);
2017-07-31 10:56:22 +08:00
}
2017-07-28 21:16:47 +08:00
})
2017-08-28 17:24:17 +08:00
return (<div className="breadcrumb-container">
<Breadcrumb>
{getItem}
</Breadcrumb>
</div>);
2017-07-28 17:30:56 +08:00
}
}