有关 Access to image at ‘file:’ from origin ‘null’ has been blocked by CORS policy 的解决办法
在使用Three.js库完成数字孪生的课题中,遇到加载本地图片报错的问题,报错内容如下:
Access to image at ‘file:///(本地绝对路径)/Earth.png’ from origin ‘null’ has been blocked by CORS policy: Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, chrome-untrusted, https.
网上有关使用chrome作为调试的解决方法简单且无效,但以防只有本电脑的个例原因,也作以描述,即
右键chrome-属性-快捷方式
在目标后的文本框中添加
–allow-file-access-from-files(前有空格)
后又经历了
tomcat
anywhere
等方法,可能由于本人非计算机专业科班出身,在校期间仅专注于机器学习,对B/S端完全小白,以上方法均失败…
最终解决方法如下:
使用vscode中的插件Live Server进行调试
注:在使用Live Server插件进行调试时,头文件中对Three.js和OrbitControls.js的引用不可以使用本地文件!
最后
以上就是快乐帆布鞋最近收集整理的关于有关 Access to image at ‘file:‘ from origin ‘null‘ has been blocked by CORS policy 的解决办法有关 Access to image at ‘file:’ from origin ‘null’ has been blocked by CORS policy 的解决办法的全部内容,更多相关有关内容请搜索靠谱客的其他文章。
发表评论 取消回复