HarmonyOS鸿蒙Next中webview load页面,页面中进行XMLHttpRequest请求文件,status=0
HarmonyOS鸿蒙Next中webview load页面,页面中进行XMLHttpRequest请求文件,status=0
webview.loadH5页面,想要在H5的js层处理文件,可是我现在在js层拿不到文件,网络请求 status=0,用XMLHttpRequest请求文件请求不到status=0,直接就进入request.onerror(),请教一下如何解决?急求!!!
另外想请教js如何拿到文件?目前了解到webview Java层能拿到,但是不知道如何传到js层
var request = new XMLHttpRequest();
request.open('GET', 'http://127.0.0.1:3000/file', true);
request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;");
request.responseType = 'blob';
request.onerror = function(e) {
console.log(e);
console.log('req err');
}
更多关于HarmonyOS鸿蒙Next中webview load页面,页面中进行XMLHttpRequest请求文件,status=0的实战教程也可以访问 https://www.itying.com/category-93-b0.html
楼主你好,建议参考官方最新的数据请求API看能否实现对应功能,参考链接:https://developer.harmonyos.com/cn/docs/documentation/doc-references/js-apis-net-http-0000001169381138
更多关于HarmonyOS鸿蒙Next中webview load页面,页面中进行XMLHttpRequest请求文件,status=0的实战系列教程也可以访问 https://www.itying.com/category-93-b0.html
哇哇哇,写的很好的样子,
你好,我在安卓上测试同样代码,添加允许跨域代码webView.getSettings().setAllowUniversalAccessFromFileURLs(true);
后可以正常请求文件,请问鸿蒙有实现类似这个函数setAllowUniversalAccessFromFileURLs
跨域功能的函数吗?我在api文档里(HarmonyOS应用开发-服务开发-Java API参考-ohos.agp.components.webengine-Interface-WebConfig)没有找到。谢谢!
项目配置
- 项目名称:HelloWorld
- 项目路径:entry
- 设备类型:手机
- 框架类型: ArkTS
- 版本号:1.0.0
- 描述:这是一个测试项目