mirror of
https://github.com/ant-design/ant-design.git
synced 2024-12-17 02:18:07 +08:00
6776bb8916
* docs: update demo * chore: add script * test: fix demo test * docs: convert demos * chore: move script * test: remove react-dom import * chore: update deps * docs: update riddle js * test: fix image test * docs: fix riddle demo
940 B
940 B
order | title | ||||
---|---|---|---|---|---|
5 |
|
zh-CN
锚点目标滚动到屏幕正中间。
en-US
Anchor target scroll to screen center.
import React, { useState, useEffect } from 'react';
import { Anchor } from 'antd';
const { Link } = Anchor;
const AnchorExample: React.FC = () => {
const [targetOffset, setTargetOffset] = useState<number | undefined>(undefined);
useEffect(() => {
setTargetOffset(window.innerHeight / 2);
}, []);
return (
<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>
);
};
export default () => <AnchorExample />;