import React from 'react'; let prefixCls = 'ant-breadcrumb'; let BreadcrumbItem = React.createClass({ propTypes: { href: React.PropTypes.string }, render() { let link = {this.props.children}; let slash = /; if (typeof this.props.href === 'undefined') { link = {this.props.children}; } return {link}{slash}; } }); let Breadcrumb = React.createClass({ propTypes: { router: React.PropTypes.object, routes: React.PropTypes.array, params: React.PropTypes.object }, render() { let crumbs; let ReactRouter = this.props.router; let routes = this.props.routes; let params = this.props.params; if (routes && routes.length > 0 && ReactRouter) { let Link = ReactRouter.Link; crumbs = routes.map(function(route, i) { if (!route.breadcrumbName) { return null; } let name = route.breadcrumbName.replace(/\:(.*)/g, function(replacement, key) { return params[key] || replacement; }); let link; let path = route.path.indexOf('/') === 0 ? route.path : ('/' + route.path); if (i === routes.length - 1) { link = {name}; } else { link = {name}; } return {link}; }); } else { crumbs = this.props.children; } return (
{crumbs}
); } }); Breadcrumb.Item = BreadcrumbItem; export default Breadcrumb;