当h5与原生webview交互时,需要实现页面数据存储功能。h5调用localStorage方法,在android 上没反应 ,尼玛坑货!看android webView原生api时才发现:原来打开本地缓存功能默认是禁止的。,需去主动打开一下就行了
webView.getSettings().setDomStorageEnabled(true); String appCachePath = getApplicationContext().getCacheDir().getAbsolutePath(); webView.getSettings().setAppCachePath(appCachePath); webView.getSettings().setAllowFileAccess(true); webView.getSettings().setAppCacheEnabled(true);
就是以上这段代码就行了!
大功告成