scrollTop 不生效时如何将页面移动到指定元素位置
{/* 要跳转的暗锚点 */}
<a id="hardware" style={{ position: "relative", top: "0" }}></a>
handleLoaction(item) {
let ele = document.querySelector(item.location);
// 减去头部导航栏的高度
ele.style.top = "-100px";
ele.scrollIntoView({ behavior: "smooth", block: "start" });
this.setState({
location: item.location,
});
}