我试图加载一个3D模型,存储在我的电脑本地,到Three.js与JSONLoader, 3D模型是在同一目录下,作为整个网站。
我得到了“跨起源请求只支持HTTP.”错误,但我不知道是什么原因导致它也不知道如何修复它。
我试图加载一个3D模型,存储在我的电脑本地,到Three.js与JSONLoader, 3D模型是在同一目录下,作为整个网站。
我得到了“跨起源请求只支持HTTP.”错误,但我不知道是什么原因导致它也不知道如何修复它。
当前回答
对于Linux Python用户:
import webbrowser
browser = webbrowser.get('google-chrome --allow-file-access-from-files %s')
browser.open(url)
其他回答
在Chrome中,你可以使用这个标志:
--allow-file-access-from-files
点击这里阅读更多。
对我来说,最快的方法是: 对于windows用户在Firefox上运行文件的问题解决了,或者 如果你想使用chrome,对我来说最简单的方法是安装Python 3,然后从命令提示符运行命令Python -m http。服务器,然后访问http://localhost:8000/,然后导航到您的文件
python -m http.server
当我下载一个页面进行离线查看时,我就遇到了这种情况。
我只需要从所有<link>和<script>标签中删除integrity="*****"和crossorigin="anonymous"属性
使用http://或https://创建url
错误:localhost: 8080
解决方案:http://localhost: 8080
我将列出3种不同的方法来解决这个问题:
Using a very lightweight npm package: Install live-server using npm install -g live-server. Then, go to that directory open the terminal and type live-server and hit enter, page will be served at localhost:8080. BONUS: It also supports hot reloading by default. Using a lightweight Google Chrome app developed by Google: Install the app, then go to the apps tab in Chrome and open the app. In the app point it to the right folder. Your page will be served! Modifying Chrome shortcut in windows: Create a Chrome browser's shortcut. Right-click on the icon and open properties. In properties, edit target to "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" --disable-web-security --user-data-dir="C:/ChromeDevSession" and save. Then using Chrome open the page using ctrl+o. NOTE: Do NOT use this shortcut for regular browsing.
注意:使用类似http://localhost:8080的http://以防出错。