mirror of
https://gitee.com/ant-design/ant-design.git
synced 2024-12-04 04:58:55 +08:00
35 lines
694 B
Markdown
35 lines
694 B
Markdown
---
|
|
order: 4
|
|
title:
|
|
zh-CN: 设置锚点滚动偏移量
|
|
en-US: Set Anchor scroll offset
|
|
---
|
|
|
|
## zh-CN
|
|
|
|
锚点目标滚动到屏幕正中间。
|
|
|
|
## en-US
|
|
|
|
Anchor target scroll to screen center.
|
|
|
|
```jsx
|
|
import { Anchor } from 'antd';
|
|
|
|
const { Link } = Anchor;
|
|
|
|
const targetOffset = window.innerHeight / 2;
|
|
|
|
ReactDOM.render(
|
|
<Anchor targetOffset={targetOffset}>
|
|
<Link href="#components-anchor-demo-basic" title="Basic demo" />
|
|
<Link href="#components-anchor-demo-static" title="Static demo" />
|
|
<Link href="#API" title="API">
|
|
<Link href="#Anchor-Props" title="Anchor Props" />
|
|
<Link href="#Link-Props" title="Link Props" />
|
|
</Link>
|
|
</Anchor>,
|
|
mountNode,
|
|
);
|
|
```
|