鍍金池/ 問答/HTML/ antd的Anchor錨點(diǎn)組件為什么沒有隨著頁面滾動變化?

antd的Anchor錨點(diǎn)組件為什么沒有隨著頁面滾動變化?

我引用的Anchor錨點(diǎn)組件只能點(diǎn)擊才能跳轉(zhuǎn)到對應(yīng)的div,不能隨著頁面滾動自動變化。代碼如下:
<Content className="wy-anchor-Content">
<Anchor>

    {   anchorList.map(item => (
      <Link key={`${item.firstIndex}${item.secondIndex}`} 
          href={`#anchor-${item.firstIndex}${item.secondIndex}`}
          title={item.title ? item.title : '處理信息'} />
        ))                           
    }

</Anchor>
</Content>

樣式如下:
.wy-anchor-Content {

    margin-top: 8px;
    font-size: 14px;
    // border: 1px solid #c1c1c1;
    padding: 4px 8px;
    background-color: #fff;
    overflow-y: auto;
    max-height: 500px;
    box-shadow: 0 1px 10px rgba(0, 0, 0, 0.2);
    .ant-anchor-link-active {
        background-color: #a7d3f0;
        .ant-anchor-link-title {
            color: #fff;
        }
    }
}
回答
編輯回答
厭遇

<Anchor target={() => document.querySelector('#wy-scroll-layout')} >

和監(jiān)聽的滾動區(qū)域有關(guān),默認(rèn)是body

2018年3月16日 22:31
編輯回答
墨染殤

可能與你wy-anchor-Content這個樣式有關(guān)吧?
就這段代碼看不出問題。

2017年5月7日 04:20