breadcrumb

This commit is contained in:
afc163 2015-07-02 18:33:37 +08:00
parent e551caddd5
commit c42ca53d91
2 changed files with 9 additions and 5 deletions

View File

@ -27,13 +27,17 @@ let Breadcrumb = React.createClass({
if (this.context.router) {
routes = this.context.router.getCurrentRoutes();
params = this.context.router.getCurrentParams();
crumbs = routes.map(function(route) {
crumbs = routes.map(function(route, i) {
var name = route.name.replace(/\:(.*)/g, function(replacement, key) {
return params[key] || replacement;
});
return <BreadcrumbItem>
<Link to={route.path} params={params}>{name}</Link>
</BreadcrumbItem>;
var link;
if (i === routes.length - 1) {
link = <span>{name}</span>;
} else {
link = <Link to={route.path} params={params}>{name}</Link>;
}
return <BreadcrumbItem>{link}</BreadcrumbItem>;
});
} else {
crumbs = this.props.children;

View File

@ -4,7 +4,7 @@
color: #999;
font-size: 12px;
a&-link {
a {
color: #666;
}