diff --git a/components/breadcrumb/demo/router.md b/components/breadcrumb/demo/router.md
index 46a7d66c89..8b8c5fbf97 100644
--- a/components/breadcrumb/demo/router.md
+++ b/components/breadcrumb/demo/router.md
@@ -15,8 +15,12 @@ const Apps = React.createClass({
render() {
return (
- - 应用1
- - 应用2
+ -
+ 应用1:详情
+
+ -
+ 应用2:详情
+
);
}
@@ -39,7 +43,7 @@ const Home = React.createClass({
}}>
点击上面的导航切换页面,面包屑在下面:
-
+
);
}
@@ -49,7 +53,9 @@ ReactDOM.render(
-
+
+
+
diff --git a/components/breadcrumb/index.jsx b/components/breadcrumb/index.jsx
index 4d4eb0c725..09711aea73 100644
--- a/components/breadcrumb/index.jsx
+++ b/components/breadcrumb/index.jsx
@@ -43,16 +43,14 @@ const Breadcrumb = React.createClass({
React.PropTypes.string,
React.PropTypes.element,
]),
- router: React.PropTypes.object,
routes: React.PropTypes.array,
- params: React.PropTypes.object
+ params: React.PropTypes.object,
},
render() {
let crumbs;
- const { separator, prefixCls, router, routes, params, children } = this.props;
- const ReactRouter = router;
- if (routes && routes.length > 0 && ReactRouter) {
- let Link = ReactRouter.Link;
+ const { separator, prefixCls, routes, params, children } = this.props;
+ if (routes && routes.length > 0) {
+ const paths = [];
crumbs = routes.map((route, i) => {
if (!route.breadcrumbName) {
return null;
@@ -60,12 +58,18 @@ const Breadcrumb = React.createClass({
const name = route.breadcrumbName.replace(/\:(.*)/g, (replacement, key) => {
return params[key] || replacement;
});
+
let link;
- const path = route.path.indexOf('/') === 0 ? route.path : ('/' + route.path);
+ let path = route.path.indexOf('/') === 0 ? route.path : ('/' + route.path);
+ Object.keys(params).forEach(key => {
+ path = path.replace(':' + key, params[key]);
+ });
+ paths.push(path);
+
if (i === routes.length - 1) {
link = {name};
} else {
- link = {name};
+ link = {name};
}
return {link};
});
diff --git a/components/breadcrumb/index.md b/components/breadcrumb/index.md
index 4010bb48a2..34685f895b 100644
--- a/components/breadcrumb/index.md
+++ b/components/breadcrumb/index.md
@@ -29,7 +29,6 @@
| 参数 | 说明 | 类型 | 可选值 | 默认值 |
|-----------|-----------------------------------|-------------------|---------|--------|
-| router | 可传入 react-router 的实例 | Object | | - |
| routes | router 的路由栈信息 | Array | | - |
| params | 路由的参数 | Object | | - |
| separator | 分隔符自定义 | String or Element | | '/' |