"跨起源请求仅支持HTTP&QUOT。错误加载本地文件时, [英] "Cross origin requests are only supported for HTTP." error when loading a local file

查看:178
本文介绍了"跨起源请求仅支持HTTP&QUOT。错误加载本地文件时,的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图加载一个三维模型到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屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆