HarmonyOS Web加载本地沙箱资源H5文件报错

HarmonyOS  Web加载本地沙箱资源H5文件报错  -鸿蒙开发者社区

HarmonyOS
2024-12-25 14:53:40
浏览
收藏 0
回答 1
回答 1
按赞同
/
按时间
FengTianYa

在web组件加下setpathallowinguniversalaccess属性

.onControllerAttached(() => {
  try {
    // 设置允许可以跨域访问的路径列表
    this.webController.setPathAllowingUniversalAccess([
      this.FILE_DIR
    ])
    // this.webController.loadUrl("file://" + getContext().resourceDir + "/index.html")
  } catch (error) {
    console.error(`ErrorCode: ${(error as BusinessError).code}, Message: ${(error as BusinessError).message}`);
  }
})
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.

参考链接:https://developer.huawei.com/consumer/cn/doc/harmonyos-references-V5/js-apis-webview-V5#setpathallowinguniversalaccess12

分享
微博
QQ
微信
回复
2024-12-25 17:29:33


相关问题
HarmonyOS Web组件加载本地H5文件跨域
704浏览 • 1回复 待解决
HarmonyOS 本地H5加载
641浏览 • 1回复 待解决
HarmonyOS Web组件加载H5白屏
562浏览 • 1回复 待解决
HarmonyOS web组件加载h5h5拉起摄像头
1220浏览 • 1回复 待解决
HarmonyOS web通过loadData加载h5标签
1085浏览 • 1回复 待解决
HarmonyOS web本地沙箱加载
669浏览 • 1回复 待解决
HarmonyOS h5 web上传图片,文件的demo
524浏览 • 1回复 待解决
HarmonyOS Web组件加载在线H5页面
703浏览 • 1回复 待解决
Web能直接加载h5代码吗?
3674浏览 • 2回复 待解决
HarmonyOS webH5交互
1322浏览 • 1回复 待解决
HarmonyOS H5展示沙箱路径里面的图片
538浏览 • 1回复 待解决
HarmonyOS WebView加载H5卡顿
625浏览 • 1回复 待解决
HarmonyOS web加载沙箱文件失败
490浏览 • 1回复 待解决
HarmonyOS 咨询下p12文件md5
372浏览 • 1回复 待解决
webview加载Vue h5失败
18356浏览 • 5回复 待解决