1.加入這個(gè)跳轉(zhuǎn)方法
//描點(diǎn)跳轉(zhuǎn)
scrollToAnchor = (anchorName) => {
if (anchorName) {
// 找到錨點(diǎn)
let anchorElement = document.getElementById(anchorName);
// 如果對(duì)應(yīng)id的錨點(diǎn)存在乏悄,就跳轉(zhuǎn)到錨點(diǎn)
if(anchorElement) { anchorElement.scrollIntoView({block: 'start', behavior: 'smooth'}); }
}
}
2.在要跳的div標(biāo)記id:'xxx'.
3.在對(duì)應(yīng)的按鈕上面執(zhí)行點(diǎn)擊方法