首先在react项目中引用antd的锚点
import {Anchor} from 'antd';
const { Link } = Anchor;
<Anchor>
<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>
//测试
<div id="components-anchor-demo-basic" style={ {marginTop:"1000px"}}>
dddd
</div>
<div id="components-anchor-demo-static" style={ {marginTop:"2000px"}}>
ffff
</div>