在混合式app項(xiàng)目中用Android的webview展示h5頁(yè)面時(shí),部分頁(yè)面點(diǎn)擊沒反應(yīng),bug定位半天終于發(fā)現(xiàn)是h5中用到localstorage的地方就會(huì)有問題,查資料后發(fā)現(xiàn)是webview需要設(shè)置后才能獲取和存儲(chǔ)localstorage,具體安卓設(shè)置如下:
webView.getSettings().setDomStorageEnabled(true);
webView.getSettings().setAppCacheMaxSize(1024*1024*8);
String appCachePath = getApplicationContext().getCacheDir().getAbsolutePath();
webView.getSettings().setAppCachePath(appCachePath);
webView.getSettings().setAllowFileAccess(true);
webView.getSettings().setAppCacheEnabled(true);
安卓webview 中加上以上設(shè)置后 h5即可愉快使用localstorage啦!