在移动端浏览器中使用localStorage
和sessionStorage
是没有任何问题的。但是在安卓webview中却出现了localStorage
无法向移动的磁盘写数据的问题。最后通过网络搜索发现。在安卓上webview是默认不开启localStorage
想磁盘写文件的权限的。所以如果需要使用localStorage
的同学需要找客户端支持。
mWebSetting.setDomStorageEnabled(true)
把一些方法保存到 localStorage里,根据需求调出来使用
var a = 'return function(){alert(1)}'
var b = (new Function(a))()
b()