2021-09-25 08:51:32 +00:00
---
category: Components
2023-04-21 09:33:38 +00:00
type: Navigation
2023-04-21 13:29:20 +00:00
cols: 1
2021-09-25 08:51:32 +00:00
title: Anchor
2023-02-23 04:21:23 +00:00
cover: https://mdn.alipayobjects.com/huamei_7uahnr/afts/img/A*TBTSR4PyVmkAAAAAAAAAAAAADrJ8AQ/original
2023-03-20 03:15:02 +00:00
coverDark: https://mdn.alipayobjects.com/huamei_7uahnr/afts/img/A*JGb3RIzyOCkAAAAAAAAAAAAADrJ8AQ/original
2021-09-25 08:51:32 +00:00
---
Hyperlinks to scroll on one page.
## When To Use
For displaying anchor hyperlinks on page and jumping between them.
## API
### Anchor Props
| Property | Description | Type | Default | Version |
| --- | --- | --- | --- | --- |
| affix | Fixed mode of Anchor | boolean | true | |
| bounds | Bounding distance of anchor area | number | 5(px) | |
| getContainer | Scrolling container | () => HTMLElement | () => window | |
2022-05-10 07:35:44 +00:00
| getCurrentAnchor | Customize the anchor highlight | (activeLink: string) => string | - | activeLink(3.3) |
2021-09-25 08:51:32 +00:00
| offsetBottom | Pixels to offset from bottom when calculating position of scroll | number | - | |
| offsetTop | Pixels to offset from top when calculating position of scroll | number | 0 | |
2023-01-25 09:23:03 +00:00
| showInkInFixed | Whether show ink-square when `: affix="false"` | boolean | false | |
2022-03-12 01:56:32 +00:00
| targetOffset | Anchor scroll offset, default as `offsetTop` , [example ](#components-anchor-demo-targetOffset ) | number | `offsetTop` | 1.5.0 |
2021-09-25 08:51:32 +00:00
| wrapperClass | The class name of the container | string | - | |
| wrapperStyle | The style of the container | object | - | |
2023-04-21 09:33:38 +00:00
| items | Data configuration option content, support nesting through children | { key, href, title, target, children }\[] [see ](#anchoritem ) | - | 4.0 |
| direction | Set Anchor direction | `vertical` \| `horizontal` | `vertical` | 4.0 |
2023-04-21 13:29:20 +00:00
| customTitle | custom option title by slot | v-slot="AnchorItem" | - | 4.0 |
2023-04-21 09:33:38 +00:00
### AnchorItem
| Property | Description | Type | Default | Version |
| --- | --- | --- | --- | --- |
| key | The unique identifier of the Anchor Link | string \| number | - | |
| href | The target of hyperlink | string | | |
| target | Specifies where to display the linked URL | string | | |
| title | The content of hyperlink | VueNode \| (item: AnchorItem) => VueNode | | |
| children | Nested Anchor Link, `Attention: This attribute does not support horizontal orientation` | [AnchorItem ](#anchoritem )\[] | - | |
2021-09-25 08:51:32 +00:00
### Events
2022-03-12 01:56:32 +00:00
| Events Name | Description | Arguments | Version | |
2021-12-04 17:06:31 +00:00
| --- | --- | --- | --- | --- |
2021-09-25 08:51:32 +00:00
| change | Listening for anchor link change | (currentActiveLink: string) => void | | 1.5.0 |
2023-01-25 09:23:03 +00:00
| click | set the handler to handle `click` event | Function(e: MouseEvent, link: Object) | | |
2021-09-25 08:51:32 +00:00
### Link Props
| Property | Description | Type | Default | Version |
| -------- | ----------------------------------------- | ------------ | ------- | ------- |
| href | target of hyperlink | string | | |
| target | Specifies where to display the linked URL | string | | 1.5.0 |
2022-03-12 01:56:32 +00:00
| title | content of hyperlink | string\|slot | | |