Cross origin requests are only supported for protocol schemes: http, data, chrom

風吹過wu發表於2018-11-22

在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);
}
複製程式碼

相關文章