From 984d8db8b1700fcddd3cd60ceccc1d75c416506c Mon Sep 17 00:00:00 2001 From: gaop Date: Wed, 17 Mar 2021 09:21:58 +0800 Subject: [PATCH] =?UTF-8?q?=E7=AE=80=E5=8C=96JS=E4=B8=AD=E7=9A=84=E8=B0=83?= =?UTF-8?q?=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 如果方法不需要参数,只有回调函数,简化JS中的调用 --- library/src/main/assets/WebViewJavascriptBridge.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/library/src/main/assets/WebViewJavascriptBridge.js b/library/src/main/assets/WebViewJavascriptBridge.js index adcf0ffa..ccbfea8d 100644 --- a/library/src/main/assets/WebViewJavascriptBridge.js +++ b/library/src/main/assets/WebViewJavascriptBridge.js @@ -36,7 +36,11 @@ } // 调用线程 function callHandler(handlerName, data, responseCallback) { - + // 如果方法不需要参数,只有回调函数,简化JS中的调用 + if (arguments.length == 2 && typeof data == 'function') { + responseCallback = data; + data = null; + } _doSend(handlerName, data, responseCallback); }