vue锚点导航



//在box中
 
gernerateId(index) { return "box" + index; }, //在锚导航中 //点击导航时 跳到对应的id custormAnchor(anchorName) { // 找到锚点 let anchorElement = document.getElementById(anchorName); // 如果对应id的锚点存在,就跳转到锚点 if (anchorElement) { anchorElement.scrollIntoView(); } }, 当页面滚动时 监听页面高度 再定位到某个锚点

 

你可能感兴趣的:(vue锚点导航)