1. ios上多个输入框点击切换后移位导致的问题

      1. // bug1
      2. mounted() {
      3. document.body.addEventListener('focusout', this.resetScroll)
      4. },
      5. destory() {
      6. document.body.removeEventListener('focusout', this.resetScroll)
      7. }
      8. // 处理ios上点击输入框后移位导致的问题
      9. resetScroll() {
      10. if (this.isIos()) {
      11. setTimeout(() => {
      12. // 当焦点在弹出层的输入框之间切换时先不归位
      13. window.scrollTo({ top: 0, left: 0, behavior: 'smooth' })
      14. }, 300)
      15. }
      16. },
      17. isIos() {
      18. var u = navigator.userAgent
      19. var isIos = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/) // ios终端
      20. return isIos
      21. }
      22. //
      23. //
      24. // bug2
      25. // fix: 修复ios中输入框未失去焦点键盘弹出时,点击开户地导致按钮错位的问题
      26. setTimeout(function() {
      27. var scrollHeight =
      28. document.documentElement.scrollTop || document.body.scrollTop || 0
      29. window.scrollTo(0, Math.max(scrollHeight - 1, 0))
      30. }, 100)
    2. 解决ios回退不刷新问题

    1. if (isIos()) {
    2. window.onpageshow = function(event) {
    3. if (event.persisted) {
    4. window.location.reload();
    5. }
    6. };
    7. }