好像 webview 打开也会受到跨域加载的限制。
比如加载图片提示如下:
file:///data/user/0/test/files/apps/fb77dedd-fee0-40dd-9a63-4e00cb6b6a89/1.0.0/index.html-line0 :Image from origin 'file://' has been blocked from loading by Cross-Origin Resource Sharing policy: Invalid response. Origin 'null' is therefore not allowed access.
8 个回复
Laya_XS
赞同来自:
helloqiner
赞同来自:
比如加载图片提示如下:
file:///data/user/0/test/files/apps/fb77dedd-fee0-40dd-9a63-4e00cb6b6a89/1.0.0/index.html-line0 :Image from origin 'file://' has been blocked from loading by Cross-Origin Resource Sharing policy: Invalid response. Origin 'null' is therefore not allowed access.
Laya_XS
赞同来自:
helloqiner
赞同来自:
应该是框架能不能帮解决本地加载的问题?或者是Laya没办法支持这种模式?
刚上手,没深入研究,为什么会有跨域的问题,使用index.html的相对路径加载不行么,为什么要跨域呢?
Laya_XS
赞同来自:
moketao
赞同来自:
如果是放在手机里,打包正确的话,layaplayer也应该能解决跨域。
如果不整合layaPlayer,那么就要放服务端了。需要服务端加个允许跨域的文件头协议,就能跨域了。
helloqiner
赞同来自:
如果能把素材放本地,直接webview加载本地文件,那就爽了,是吧
moketao
赞同来自: