我希望将 AJAX 调用迁移到 FETCH API。我可以在 android webview 上这样做:
httpGet("data//app:customers")
function httpGet(theUrl)
{
var xmlHttp = new XMLHttpRequest();
xmlHttp.open( "GET", theUrl, false ); // false for synchronous request
xmlHttp.send( null );
return xmlHttp.responseText;
}
并被拦截:
override this.ShouldInterceptRequest(view:WebView, request:IWebResourceRequest) =
let rows = Customer.fakeData 1
let st = Shared.jsonToStream(rows)
new WebResourceResponse("application/javascript", "UTF-8", st)
但是,如果我尝试使用:
fetch("data//app:customers").then(function(data){return data})
我得到错误:
VM44:1 Fetch API cannot load file:///android_asset/data//app:customers. URL scheme "file" is not supported.
最佳答案
您不能将 Fetch API 用于 file://协议(protocol)。它只接受 HTTP 协议(protocol)。
关于android - 如何在 android 上使用 WebView FETCH api 调用自定义 url,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48122162/