在Android 4.2以後webView載入本地的html。如果是通過file的方式訪問,就會報如下的錯誤
zepto.js:1533 Failed to load file:///storage/emulated/0/Android/data/com.xx.xx.android/files/app/plugins/portal/i18n/MResource_zh-CN.properties?_=1542848384751: Cross origin requests are only supported for protocol schemes: http, data, chrome, https.
複製程式碼
解決方法:
if (Build.VERSION.SDK_INT >= 16) {
webView.getSettings().setAllowFileAccessFromFileURLs(true);
}
複製程式碼