"跨起源请求仅支持HTTP&QUOT。错误加载本地文件时, [英] "Cross origin requests are only supported for HTTP." error when loading a local file
问题描述
我试图加载一个三维模型到Three.js与 JSONLoader
,以及三维模型在同一目录中的整个网站。
I'm trying to load a 3D model into Three.js with JSONLoader
, and that 3D model is in the same directory as the entire website.
我发现了跨起源请求仅支持HTTP。
的错误,但我不知道是什么原因引起的,也没有如何解决它。
I'm getting the "Cross origin requests are only supported for HTTP."
error, but I don't know what's causing it nor how to fix it.
推荐答案
我的水晶球说,你正在使用文件加载模型://
或 C:/
,它保持真实的错误消息,因为它们不是的http://
My crystal ball says that you are loading the model using either file://
or C:/
, which stays true to the error message as they are not http://
所以,你可以安装一个Web服务器在本地PC或上传的模式在其他地方,并使用 JSONP
并更改网址 HTTP:/ /example.com/path/to/model
So you can either install a webserver in your local PC or upload the model somewhere else and use jsonp
and change the url to http://example.com/path/to/model
这篇关于"跨起源请求仅支持HTTP&QUOT。错误加载本地文件时,的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!