Merge pull request #1030 from ant-design/feat-breadcrumb-linkrender

Feat breadcrumb linkrender
This commit is contained in:
Benjy Cui 2016-03-08 17:23:33 +08:00
commit 8def2ac9d3
2 changed files with 5 additions and 3 deletions

View File

@ -35,6 +35,7 @@ const Breadcrumb = React.createClass({
return {
prefixCls: 'ant-breadcrumb',
separator: '/',
linkRender: (href, name) => <a href={`#${href}`}>{name}</a>,
};
},
propTypes: {
@ -48,7 +49,7 @@ const Breadcrumb = React.createClass({
},
render() {
let crumbs;
const { separator, prefixCls, routes, params, children } = this.props;
const { separator, prefixCls, routes, params, children, linkRender } = this.props;
if (routes && routes.length > 0) {
const paths = [];
crumbs = routes.map((route, i) => {
@ -71,7 +72,7 @@ const Breadcrumb = React.createClass({
if (i === routes.length - 1) {
link = <span>{name}</span>;
} else {
link = <a href={`#/${paths.join('/')}`}>{name}</a>;
link = linkRender(`/${paths.join('/')}`, name);
}
return <BreadcrumbItem separator={separator} key={name}>{link}</BreadcrumbItem>;
});

View File

@ -11,7 +11,7 @@
## 何时使用
- 当系统拥有超过两级以上的层级结构时;
- 当需要告知用户“你在哪里”时;
- 当需要告知用户『你在哪里』时;
- 当需要向上导航的功能时。
## API
@ -32,6 +32,7 @@
| routes | router 的路由栈信息 | Array | | - |
| params | 路由的参数 | Object | | - |
| separator | 分隔符自定义 | String or Element | | '/' |
| linkRender | 自定义链接函数,和 react-router 配置使用 | Function(href, name) | | - |
### Breadcrumb.Item