锚点

crollToAnchor = anchorName => {
        if (anchorName) {
            // 找到锚点
            const anchorElement = document.getElementById(anchorName);
            // 如果对应id的锚点存在,就跳转到锚点
            if (anchorElement) {
            anchorElement.scrollIntoView({ block: "start", behavior: "smooth" });
            }
        }
    };
posted @ 2020-04-15 15:58  浪浪浪浪浪浪浪浪  阅读(227)  评论(0编辑  收藏  举报