mirror of
https://github.com/ant-design/ant-design.git
synced 2024-11-30 06:09:34 +08:00
907 B
907 B
order | title | ||||
---|---|---|---|---|---|
5 |
|
zh-CN
锚点目标滚动到屏幕正中间。
en-US
Anchor target scroll to screen center.
import { Anchor } from 'antd';
const { Link } = Anchor;
const AnchorExample: React.FC = () => {
const [targetOffset, setTargetOffset] = React.useState<number | undefined>(undefined);
React.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>
);
};
ReactDOM.render(<AnchorExample />, mountNode);