使用android直接打开h5的链接,报错localStorage.setItem为null
原因是要打开Android的webview的存储设置
val webView = findViewById<WebView>(R.id.webview)
val settings = webView.settings
settings.domStorageEnabled = true
settings.databaseEnabled = true
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) {
settings.databasePath = "/data/data/" + webView.context.packageName + "/databases/";
}
这样在uniapp中使用uni.setStorageSync才能行,以及获取getStorageSync才不会报错。
标签:uniapp,settings,h5,Android,webview,null,webView From: https://www.cnblogs.com/xxss0903/p/17982963