2016-10-28 14:02:55 +08:00
|
|
|
---
|
|
|
|
category: Components
|
2016-12-30 21:41:28 +08:00
|
|
|
type: Other
|
2016-11-18 17:02:57 +08:00
|
|
|
cols: 2
|
2016-10-28 14:02:55 +08:00
|
|
|
title: Anchor
|
2020-06-05 13:50:09 +08:00
|
|
|
cover: https://gw.alipayobjects.com/zos/alicdn/_1-C1JwsC/Anchor.svg
|
2016-10-28 14:02:55 +08:00
|
|
|
---
|
|
|
|
|
2016-11-09 21:06:43 +08:00
|
|
|
Hyperlinks to scroll on one page.
|
2016-10-28 14:02:55 +08:00
|
|
|
|
|
|
|
## When To Use
|
|
|
|
|
2016-11-29 17:13:24 +08:00
|
|
|
For displaying anchor hyperlinks on page and jumping between them.
|
2016-10-28 14:02:55 +08:00
|
|
|
|
|
|
|
## API
|
|
|
|
|
2016-11-03 16:45:13 +08:00
|
|
|
### Anchor Props
|
|
|
|
|
2019-07-11 14:14:33 +08:00
|
|
|
| Property | Description | Type | Default | Version |
|
|
|
|
| --- | --- | --- | --- | --- |
|
|
|
|
| affix | Fixed mode of Anchor | boolean | true | |
|
2020-07-02 17:26:33 +08:00
|
|
|
| bounds | Bounding distance of anchor area | number | 5 | |
|
2019-11-21 19:58:41 +08:00
|
|
|
| getContainer | Scrolling container | () => HTMLElement | () => window | |
|
2020-10-21 10:33:43 +08:00
|
|
|
| getCurrentAnchor | Customize the anchor highlight | () => string | - | |
|
2019-07-11 14:14:33 +08:00
|
|
|
| offsetTop | Pixels to offset from top when calculating position of scroll | number | 0 | |
|
2020-09-14 19:04:36 +08:00
|
|
|
| showInkInFixed | Whether show ink-balls when `affix={false}` | boolean | false | |
|
2020-06-17 23:18:14 +08:00
|
|
|
| targetOffset | Anchor scroll offset, default as `offsetTop`, [example](#components-anchor-demo-targetOffset) | number | - | |
|
2019-11-21 19:58:41 +08:00
|
|
|
| onChange | Listening for anchor link change | (currentActiveLink: string) => void | | |
|
2020-10-21 10:33:43 +08:00
|
|
|
| onClick | Set the handler to handle `click` event | function(e: Event, link: Object) | - | |
|
2016-11-03 16:45:13 +08:00
|
|
|
|
2016-11-07 11:04:36 +08:00
|
|
|
### Link Props
|
2016-10-28 14:02:55 +08:00
|
|
|
|
2021-03-01 19:20:48 +08:00
|
|
|
| Property | Description | Type | Default | Version |
|
|
|
|
| --- | --- | --- | --- | --- |
|
|
|
|
| href | The target of hyperlink | string | | |
|
|
|
|
| target | Specifies where to display the linked URL | string | | |
|
|
|
|
| title | The content of hyperlink | ReactNode | | |
|