About the processing of the scroll bar in the mask panel

When the mask panel is open:

  // 固定body
    fixedBody() {
    
    
      const scrollTop =
        document.body.scrollTop || document.documentElement.scrollTop;
      this.prevBodyCss = document.body.style.cssText;
      document.body.style.cssText +=
        "position:fixed;width:100%;top:-" + scrollTop + "px;";
    }

When the mask panel is closed:

   // 释放body
    looseBody() {
    
    
      const body = document.body;
      const top = body.style.top;
      body.style.cssText = this.prevBodyCss;
      body.scrollTop = document.documentElement.scrollTop = -parseInt(top);
      body.style.top = "";
    }

Guess you like

Origin blog.csdn.net/var_deng/article/details/111280029