android - 如何在 android 上使用 WebView FETCH api 调用自定义 url

标签 android f# android-webview fetch-api

我希望将 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/

相关文章:

javascript - Android WebView JavascriptInterface 属性

android - 如何使用 HitTestResult 检测 Android WebView 中的视频?

android - 解决android webview中redirect过多的问题

java - 类转换异常 : MainActivity cannot be cast to Listener

f# - FsUnit 示例错误

c# - 来自 C# 的 F# 区分联合用法

f# - 为什么我不能通过一个受歧视工会的成员列表来简化这个迭代?

android - webview.java 中的 NullPointerException (android.webkit.WebView$PrivateHandler.handleMessage)

c# - Android Activity 的滑入/滑出动画。这个设置可以吗?

android - 应用看不到模块的 Activity