Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

第一次点击锚点,会刷新页面,重新渲染,不管是a标签还是antd的Anchor都会,但是我看antd的demo就没有这个问题?路由用的umi

锚点代码

 <Anchor style={{ position: 'fixed', right: '10%', top: '50%' }}>
      <Link href="#ProductOverview" title="第1个锚点" />
      <Link href="#PositionTestPortfolio" title="第2个锚点" />
      <Link href="#PerformanceAnalysis" title="第3个锚点" />
      <Link href="#ScenarioAnalysis2" title="第4个锚点" />
      <Link href="#top" title="返回顶部" />

    </Anchor>

路由配置
`

 hash: true,
  antd: {},
  dva: {
    hmr: true,
  },
  locale: {
   
    default: 'zh-CN',
    antd: true,
    baseNavigator: true,
  },
  dynamicImport: {
    loading: '@/components/xx',
  },
  targets: {
    ie: 11,
  },

`


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
233 views
Welcome To Ask or Share your Answers For Others

1 Answer

hash路由监听#后的hash值跳转页面, 锚点改变的就是hash值, 其实你的页面不是在刷新, 而是在跳转
帮你搜了篇文章hash 路由如何使用锚点


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...