2016-10-28 14:02:55 +08:00
|
|
|
|
---
|
|
|
|
|
category: Components
|
|
|
|
|
subtitle: 锚点
|
2016-11-18 17:02:57 +08:00
|
|
|
|
cols: 2
|
2018-11-04 16:20:35 +08:00
|
|
|
|
type: 其他
|
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 14:22:38 +08:00
|
|
|
|
用于跳转到页面指定位置。
|
2016-10-28 14:02:55 +08:00
|
|
|
|
|
|
|
|
|
## 何时使用
|
|
|
|
|
|
2016-11-03 16:45:13 +08:00
|
|
|
|
需要展现当前页面上可供跳转的锚点链接,以及快速在锚点之间跳转。
|
2016-10-28 14:02:55 +08:00
|
|
|
|
|
2022-10-31 14:49:43 +08:00
|
|
|
|
> 开发者注意事项:
|
|
|
|
|
>
|
|
|
|
|
> 自 `4.24.0` 起,由于组件从 class 重构成 FC,之前一些获取 `ref` 并调用内部实例方法的写法都会失效
|
|
|
|
|
|
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
|
|
|
|
| 成员 | 说明 | 类型 | 默认值 | 版本 |
|
|
|
|
|
| --- | --- | --- | --- | --- |
|
|
|
|
|
| affix | 固定模式 | boolean | true | |
|
2020-07-02 17:26:33 +08:00
|
|
|
|
| bounds | 锚点区域边界 | number | 5 | |
|
2019-11-21 19:58:41 +08:00
|
|
|
|
| getContainer | 指定滚动的容器 | () => HTMLElement | () => window | |
|
2022-03-31 11:17:17 +08:00
|
|
|
|
| getCurrentAnchor | 自定义高亮的锚点 | (activeLink: string) => string | - | |
|
2019-07-11 14:14:33 +08:00
|
|
|
|
| offsetTop | 距离窗口顶部达到指定偏移量后触发 | number | | |
|
2020-09-14 19:04:36 +08:00
|
|
|
|
| showInkInFixed | `affix={false}` 时是否显示小圆点 | boolean | false | |
|
2020-06-17 23:18:14 +08:00
|
|
|
|
| targetOffset | 锚点滚动偏移量,默认与 offsetTop 相同,[例子](#components-anchor-demo-targetOffset) | number | - | |
|
2020-07-02 17:26:33 +08:00
|
|
|
|
| onChange | 监听锚点链接改变 | (currentActiveLink: string) => void | - | |
|
2020-10-21 10:33:43 +08:00
|
|
|
|
| onClick | `click` 事件的 handler | function(e: Event, link: Object) | - | |
|
2016-11-07 11:04:36 +08:00
|
|
|
|
|
|
|
|
|
### Link Props
|
2016-10-28 14:02:55 +08:00
|
|
|
|
|
2022-03-31 11:17:17 +08:00
|
|
|
|
| 成员 | 说明 | 类型 | 默认值 | 版本 |
|
|
|
|
|
| ------ | -------------------------------- | --------- | ------ | ---- |
|
|
|
|
|
| href | 锚点链接 | string | - | |
|
|
|
|
|
| target | 该属性指定在何处显示链接的资源。 | string | - | |
|
|
|
|
|
| title | 文字内容 | ReactNode | - | |
|