页面禁止滚动

export function scroll(isScroll,num=0) {
  if (isScroll) {
    document.body.style.overflow = "auto";
    document.documentElement.style.overflow = "auto";
  } else {
    document.body.style.overflow = "hidden";
    document.documentElement.style.overflow = "hidden";
  }
  if(num) {
    window.scrollTo({
      top: num,
      behavior: 'smooth'
    })
  }
}

全局不能滚动

 document.body.style.overflow = "hidden";
 document.documentElement.style.overflow = "hidden";

你可能感兴趣的:(javascript)