Files
knowledge-kit/Chapter2 - Web FrontEnd/2.14.md
2020-02-25 17:46:51 +08:00

19 lines
823 B
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Web 与 H5 交互的坑
1、遇到一个问题 ,一个功能在 iOS 手机上正常工作,但是在 Android 上不正常依照经验来看无非就是2个原因1、URL参数少传递了2、JS 在移动端的 webview 上报错了,所以我让远程对接的人员将 url 打印出来,发现没错。继续让他打印查看下 js 错误日志,发现 “Cannot read property "getItem" of null”。 代码出错行数在 259。看了下具体代码就是读取 localstorage
![报错信息](https://raw.githubusercontent.com/FantasticLBP/knowledge-kit/master/assets/Andoid_Webview_Localstroage_erroe.jpg)
想了想,在我们的项目中 Android 原生的代码在使用 webview 的时候额外设置了代码具体如下
```
mWebView.getSettings().setDomStorageEnabled(true);
```