From 31f7f5d11d930535c76450d4654452b0c57236fa Mon Sep 17 00:00:00 2001 From: naiyiwang Date: Tue, 12 Feb 2019 17:37:43 +0800 Subject: [PATCH] =?UTF-8?q?bugfix:=20=E4=BF=AE=E5=A4=8Dsku=E7=BB=84?= =?UTF-8?q?=E4=BB=B6=E7=95=99=E8=A8=80=E7=82=B9=E5=87=BB=E9=94=99=E4=BD=8D?= =?UTF-8?q?=E9=97=AE=E9=A2=98=20(#2722)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/sku/components/SkuMessages.js | 11 ++++++++++- packages/utils/index.ts | 5 +++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/packages/sku/components/SkuMessages.js b/packages/sku/components/SkuMessages.js index 89aac5dca..1cc450e1a 100644 --- a/packages/sku/components/SkuMessages.js +++ b/packages/sku/components/SkuMessages.js @@ -1,4 +1,4 @@ -import { use } from '../../utils'; +import { use, isIOS } from '../../utils'; import Cell from '../../cell'; import CellGroup from '../../cell-group'; import Field from '../../field'; @@ -118,6 +118,14 @@ export default sfc({ } } } + }, + handleBlur() { + // https://developers.weixin.qq.com/community/develop/doc/00044ae90742f8c82fb78fcae56800 + // 修复ios12键盘弹起后点击错位的问题 + /* istanbul ignore next */ + if (isIOS()) { + window.scrollTo(0, 0); + } } }, @@ -147,6 +155,7 @@ export default sfc({ required={String(message.required) === '1'} placeholder={this.getPlaceholder(message)} type={this.getType(message)} + onBlur={this.handleBlur} /> )))} diff --git a/packages/utils/index.ts b/packages/utils/index.ts index 2425ac177..4f8b3a78a 100644 --- a/packages/utils/index.ts +++ b/packages/utils/index.ts @@ -36,6 +36,11 @@ export function isAndroid(): boolean { return isServer ? false : /android/.test(navigator.userAgent.toLowerCase()); } +export function isIOS(): boolean { + /* istanbul ignore next */ + return isServer ? false : /ios|iphone|ipad|ipod/.test(navigator.userAgent.toLowerCase()); +} + export function range(num: number, min: number, max: number): number { return Math.min(Math.max(num, min), max); }