问: 页面锚点如何导航
答:
『方案一』:为锚点添加点击事件
scrollToAnchor = (anchorName) => { if(anchorName) { let anchorEle = document.getElementById(anchorName); if(anchorEle) { anchorEle.scrollIntoView(); } } }
添加点击
<a onClick={()=> scrollToAnchor(name)}>click me </a>