5***@qq.com
5***@qq.com
  • 发布:2021-01-11 18:34
  • 更新:2022-07-05 16:46
  • 阅读:572

【报Bug】加载本地文件提示跨域了

分类:HTML5+

产品分类: HTML5+

HBuilderX版本号: 3.0.5

手机系统: iOS

手机系统版本号: IOS 14

手机厂商: 苹果

手机机型: 11 Pro

打包方式: 云端

操作步骤:

预期结果:

实际结果:

bug描述:

Cross origin requests are only supported for HTTP.
安卓无此问题,仅仅是IOS环境下

IOS 13,14 都有此问题
IOS模拟器也有此问题

2021-01-11 18:34 负责人:无 分享
已邀请:
baiyun_rain

baiyun_rain - 多敲代码

请问解决了吗

BoredApe

BoredApe - 有问题就会有答案。

直接使用file://引入会出现跨域问题。可以参考一下《网赚游戏》中首页使用web-view的方式来解决跨域问题。

<web-view v-if="platform=='android'" :src="'/hybrid/html/plugins/h5/index.html'" class="webview" ref="iframe"></web-view>    
<web-view v-if="platform=='ios'" :src="'http://localhost:13131/_www/hybrid/html/plugins/h5/index.html'" class="webview" ></web-view>

iOSmanifest.json中开启miniserve,安卓不需要特殊配置

"capabilities" : {    
    "plists" : {    
        "DCloudConfig" : {    
            "miniServer" : true    
        }    
    }    
}

试试这种方式能否解决问题。

  • baiyun_rain

    好,谢谢。我试试

    2022-07-05 17:37

要回复问题请先登录注册