mirror of
https://github.com/ant-design/ant-design.git
synced 2024-11-25 03:29:59 +08:00
support linkRender in breadcrumb, fix #1026
This commit is contained in:
parent
e44a9423a5
commit
27e879f444
@ -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>;
|
||||
});
|
||||
|
@ -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
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user