Used to jump to the specified location on the page.
Examples
Not fixed position
It can be displayed in an unfixed position.
Fixed position
Anchor position can be fixed by setting affix and offsetTop or offsetBottom
Set offset
The highlight is activated when the scroll offset of the anchor target is within the set offset of the container element.
Properties
Anchor
When
affixis enabled, the effect is the same as Affix
| Property | Description | Type | Default | Require |
|---|---|---|---|---|
| affix | Whether to enable fixed mode | boolean | true | false |
| affixTarget | The element referenced when fixed, the same as scrollTarget when not passed | Window | HTMLElement | (() => Window | HTMLElement) | () => window | false |
| scrollTarget | Container when scrolling, same as scrollTarget when not passed | Window | HTMLElement | (() => Window | HTMLElement) | () => window | false |
| offsetTop | ReferenceAffix | number | - | false |
| offsetBottom | ReferenceAffix | number | - | false |
| bounds | Anchor Region Boundary | number | 5 | false |
| targetOffset | Anchor scroll offset | number | 0 | false |
| onChange | Listen for anchor link changes | (currentActiveLink: string) => void | - | false |
AnchorLink
| Property | Description | Type | Default | Require |
|---|---|---|---|---|
| title | Title | string | - | true |
| href | Anchor href | string | - | true |
Methods
Anchor
| Method | Description | Type | Default |
|---|---|---|---|
| scrollTo | scroll to the specified link | (activeLink: string) => void | - |