【问题标题】:when will android webview js catch error?android webview js什么时候会捕获错误?
【发布时间】:2019-09-30 00:20:10
【问题描述】:

我在应用程序中创建了一个 webview 和一些 js 绑定。
出于安全原因,我将 js 桥接功能包装在 try catch 中。
但是,我不知道 js catch 函数捕获了什么。 因为错误是随机发生的,所以我通过 GA 发出错误但未设置事件值。

    try {
      price = JsBridge.getProductPriceString('something wrogn');
    } catch (e) {
      ga('send', 'event', 'Error', 'Exception', e && e.toString());
      console.log("getPriceString", e);
      alert("get price string error:", e);
    }

我认为我可以从 Android java 方面进行调查。
但是不知道Android js绑定什么时候会触发js catch函数?

【问题讨论】:

    标签: javascript android logging android-webview bridge


    【解决方案1】:

    您可以像通常在 Android 中一样使用调试

    Log.d("tag", "exception")

    如果你使用alertconsole.log 不能直接在Android 中工作

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-11-14
      • 1970-01-01
      • 1970-01-01
      • 2016-12-10
      相关资源
      最近更新 更多