From f9658136ebc78056a6dd8ab4d491fb8970429612 Mon Sep 17 00:00:00 2001 From: qiang Date: Tue, 19 Nov 2019 17:48:49 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20v3-app=20=E4=BF=9D=E8=AF=81iOS=E7=82=B9?= =?UTF-8?q?=E5=87=BB=E8=BE=93=E5=85=A5=E6=A1=86=E5=A4=96=E9=9A=90=E8=97=8F?= =?UTF-8?q?=E9=94=AE=E7=9B=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/core/view/mixins/keyboard.js | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/core/view/mixins/keyboard.js b/src/core/view/mixins/keyboard.js index c6b1071f6..aa8a35749 100644 --- a/src/core/view/mixins/keyboard.js +++ b/src/core/view/mixins/keyboard.js @@ -1,6 +1,10 @@ function hideKeyboard () { document.activeElement.blur() } +/** + * 保证iOS点击输入框外隐藏键盘 + */ +function iosHideKeyboard () { } export default { name: 'Keyboard', @@ -27,7 +31,7 @@ export default { } }, beforeDestroy () { - UniViewJSBridge.unsubscribe('hideKeyboard', hideKeyboard) + this.onKeyboardHide() }, methods: { plusReady (callback) { @@ -42,11 +46,10 @@ export default { initKeyboard (el) { el.addEventListener('focus', () => { UniViewJSBridge.subscribe('hideKeyboard', hideKeyboard) + document.addEventListener('click', iosHideKeyboard, false) this.setSoftinputTemporary() }) - el.addEventListener('blur', () => { - UniViewJSBridge.unsubscribe('hideKeyboard', hideKeyboard) - }) + el.addEventListener('blur', this.onKeyboardHide) }, showSoftKeybord () { this.plusReady(() => { @@ -69,6 +72,10 @@ export default { } }) }) + }, + onKeyboardHide () { + UniViewJSBridge.unsubscribe('hideKeyboard', hideKeyboard) + document.removeEventListener('click', iosHideKeyboard, false) } } } -- GitLab