fix: Anchor.Link add add new property target (#18335)

* fix: Anchor.Link add add new property target

* docs: update doc of anchor
This commit is contained in:
DiamondYuan 2019-08-19 11:10:06 +08:00 committed by 偏右
parent 8345554cd7
commit a5f1fc80fd
5 changed files with 26 additions and 9 deletions

View File

@ -8,6 +8,7 @@ import { ConfigConsumer, ConfigConsumerProps } from '../config-provider';
export interface AnchorLinkProps {
prefixCls?: string;
href: string;
target: string;
title: React.ReactNode;
children?: React.ReactNode;
className?: string;
@ -52,7 +53,7 @@ class AnchorLink extends React.Component<AnchorLinkProps, any> {
};
renderAnchorLink = ({ getPrefixCls }: ConfigConsumerProps) => {
const { prefixCls: customizePrefixCls, href, title, children, className } = this.props;
const { prefixCls: customizePrefixCls, href, title, children, className, target } = this.props;
const prefixCls = getPrefixCls('anchor', customizePrefixCls);
const active = this.context.antAnchor.activeLink === href;
const wrapperClassName = classNames(className, `${prefixCls}-link`, {
@ -67,6 +68,7 @@ class AnchorLink extends React.Component<AnchorLinkProps, any> {
className={titleClassName}
href={href}
title={typeof title === 'string' ? title : ''}
target={target}
onClick={this.handleClick}
>
{title}

View File

@ -41,6 +41,18 @@ exports[`renders ./components/anchor/demo/basic.md correctly 1`] = `
Static demo
</a>
</div>
<div
class="ant-anchor-link"
>
<a
class="ant-anchor-link-title"
href="#components-anchor-demo-basic"
target="_blank"
title="Basic demo with Target"
>
Basic demo with Target
</a>
</div>
<div
class="ant-anchor-link"
>

View File

@ -22,6 +22,7 @@ ReactDOM.render(
<Anchor>
<Link href="#components-anchor-demo-basic" title="Basic demo" />
<Link href="#components-anchor-demo-static" title="Static demo" />
<Link href="#components-anchor-demo-basic" title="Basic demo with Target" target="_blank" />
<Link href="#API" title="API">
<Link href="#Anchor-Props" title="Anchor Props" />
<Link href="#Link-Props" title="Link Props" />

View File

@ -29,7 +29,8 @@ For displaying anchor hyperlinks on page and jumping between them.
### Link Props
| Property | Description | Type | Default | Version |
| -------- | -------------------- | ----------------- | ------- | ------- |
| href | target of hyperlink | string | | |
| title | content of hyperlink | string\|ReactNode | | |
| Property | Description | Type | Default | Version |
| -------- | ----------------------------------------- | ----------------- | ------- | ------- |
| href | target of hyperlink | string | | |
| title | content of hyperlink | string\|ReactNode | | |
| target | Specifies where to display the linked URL | string | | |

View File

@ -30,7 +30,8 @@ title: Anchor
### Link Props
| 成员 | 说明 | 类型 | 默认值 | 版本 |
| ----- | -------- | ----------------- | ------ | ---- |
| href | 锚点链接 | string | | |
| title | 文字内容 | string\|ReactNode | | |
| 成员 | 说明 | 类型 | 默认值 | 版本 |
| ------ | -------------------------------- | ----------------- | ------ | ---- |
| href | 锚点链接 | string | | |
| title | 文字内容 | string\|ReactNode | | |
| target | 该属性指定在何处显示链接的资源。 | string | | |