乐趣区

关于前端:滚动定位到指定位置

const flowDetailDivMenu = document.getElementById(“flowDetailDivMenu”);

  const approveListDivMenu = document.getElementById("approveListDivMenu");
  let detailBoxDivTop = flowDetailDivMenu ? flowDetailDivMenu.offsetTop : 0;
  let approveDivTop = approveListDivMenu ? approveListDivMenu.offsetTop : 0;

  setTimeout(() => {
    //-10 是为了上边留一点红色间距
    if (key === "detail") {
      window.scrollTo({top: detailBoxDivTop-10, // this.heightToTop(document.getElementById("flowDetailBox")),
        behavior: "instant"
      });
    } else if (key === "myCare") {window.scrollTo(0, 0);
    } 

    setTimeout(() => {window.addEventListener("scroll", this.myMenuTopScroll);
    }, 280);
  }, 10);
退出移动版