From 56687ff9cb7c7e49cefefa2ae1bede0749557ccf Mon Sep 17 00:00:00 2001 From: qiang Date: Fri, 15 Apr 2022 17:53:14 +0800 Subject: [PATCH] =?UTF-8?q?fix(h5):=20=E4=BF=AE=E5=A4=8D=E5=B0=8F=E7=B1=B3?= =?UTF-8?q?=E6=89=8B=E6=9C=BA=E9=83=A8=E5=88=86=E5=BA=94=E7=94=A8=EF=BC=88?= =?UTF-8?q?=E5=A6=82=E9=92=89=E9=92=89=EF=BC=89=E5=AF=86=E7=A0=81=E9=94=AE?= =?UTF-8?q?=E7=9B=98=E6=97=A0=E6=B3=95=E6=98=BE=E7=A4=BA=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/uni-components/src/helpers/useKeyboard.ts | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/packages/uni-components/src/helpers/useKeyboard.ts b/packages/uni-components/src/helpers/useKeyboard.ts index 028360ca2..d03f6aefa 100644 --- a/packages/uni-components/src/helpers/useKeyboard.ts +++ b/packages/uni-components/src/helpers/useKeyboard.ts @@ -1,4 +1,4 @@ -import { Ref, watch } from 'vue' +import { Ref, watch, computed } from 'vue' import { CustomEventTrigger } from './useEvent' import { plusReady } from '@dcloudio/uni-shared' @@ -136,6 +136,9 @@ export function useKeyboard( const state = {} function initKeyboard(el: HTMLElement) { let focus: boolean + const isApple = computed( + () => String(navigator.vendor).indexOf('Apple') === 0 + ) const keyboardChange = () => { trigger('keyboardheightchange', {} as Event, { @@ -229,7 +232,7 @@ export function useKeyboard( } // 修复ios端显示与点击位置错位的Bug by:wyq - if (String(navigator.vendor).indexOf('Apple') === 0) { + if (isApple.value) { document.documentElement.scrollTo( document.documentElement.scrollLeft, document.documentElement.scrollTop @@ -240,7 +243,9 @@ export function useKeyboard( el.addEventListener('blur', () => { // 在iOS设备上,手动调用uni.hideKeyboard(),键盘收起并且触发blur,但实际并没有blur。 // 此时如果再点击页面其他地方会重新聚焦,此处做处理 - el.blur() + if (isApple.value) { + el.blur() + } focus = false onKeyboardHide() }) -- GitLab