【发布时间】:2014-10-25 18:42:41
【问题描述】:
我正在尝试在 webView 和 CordovaWebView 之间共享活动中的数据。 CordovaWebView 当然使用 webView,这就是为什么我不明白为什么存储在我的 phoneGap 应用程序的 localStorage 中的数据在简单的 webView 中不可见,它从与主应用程序相同的位置加载 html 页面。我已经调查过 CordovaWebView 存储的数据存储在文件 /app_webview/Local Storage/file__0.localstorage 中,数据存储在 webView 类存储在文件 /app_webview/Local Storage/__0.localstorage 中,这就是我无法访问数据的原因。 我正在将存储在 localStorage 中的数据的脚本加载到 webView,如下所示:
webView.loadUrl("file:///android_asset/www/script.html");
CordovaWebView 中的主页面加载方式相同:
void loadUrlNow(String url) {
if (LOG.isLoggable(LOG.DEBUG) && !url.startsWith("javascript:")) {
LOG.d(TAG, ">>> loadUrlNow()");
}
if (url.startsWith("file://") || url.startsWith("javascript:") || Config.isUrlWhiteListed(url)) {
super.loadUrl(url);
}
}
网址在哪里
file:///android_asset/www/index.html
那么为什么在 CordovaWebView 中 localStorage 保存在文件中
/app_webview/Local Storage/file__0.localstorage
在文件中的 webview 中
/app_webview/Local Storage/__0.localstorage
【问题讨论】:
标签: android cordova webview local-storage ionic-framework