Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

解决WebViewJavascriptBridge: WARNING: javascript handler threw.", source: (1) #194

Open
baolw opened this issue Sep 12, 2019 · 2 comments

Comments

@baolw
Copy link

baolw commented Sep 12, 2019

其实这个问题,只是因为作者对数据的转换有点不严谨。。
发生这种错误的原因。在作者库的library下的assets中有个js文件,错误是在那里面出现的。。

重点来了!!!!

由于作者对数据的转换没规范好。。

这里总结如下:
两边互传数据最好做的是严格意义上的json字符串。

最后一点,也是最重要的一点。
try {
handler(message.data, responseCallback);
} catch (exception) {
if (typeof console != 'undefined') {
console.log("WebViewJavascriptBridge: WARNING: javascript handler threw.", message, exception);
}
}

上面的错误,是发生在WebViewJavascriptBridge.js的这里。。这里try catch发生错误。handler是js端给到的处理函数,也就是在js端的这个处理函数里发生任何错误,都会出现这个错误提示。导致大家无法获取准确的错误。

@baolw
Copy link
Author

baolw commented Sep 12, 2019

所以如果出现这个错误。首先检查js端的代码。。js端发生错误,就报上面的错误。所以首要是去找js端的错误。

@YummyLau
Copy link

是的。。。json问题我们也踩过坑。。。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants