The page does not rebound after the input box of the mobile terminal is entered

  Problem: The mobile terminal gets the focus on the input box, brings up the keyboard, and the page is topped. After the input is complete, click Finish, the keyboard will be folded, but the page will not rebound.

  isWeiXinAndIos() {
    const ua = `${window.navigator.userAgent.toLowerCase()}`;
    const isWeixin = /MicroMessenger/i.test(ua);
    const isIos = /\(i[^;]+;( U;)? CPU.+Mac OS X/i.test(ua);
    return isWeixin && isIos;
  }
 
  weChatInputBug() { // 解决微信键盘收起页面不回弹的问题
    let myFunction;
    const isWXAndIos = this.isWeiXinAndIos();
    if (isWXAndIos) {
      document.body.addEventListener('focusin', () => {
        clearTimeout(myFunction);
      });
      document.body.addEventListener('focusout', () => {
        clearTimeout(myFunction);
        myFunction = setTimeout(() => {
          window.scrollTo({ top: 0, left: 0, behavior: 'smooth' });
        }, 200);
      });
    }
  }

 

Guess you like

Origin blog.csdn.net/z00001993/article/details/107310738