PixiJS服务器无法正常工作,客户端连接时出现“本地主机发送无效响应”错误
当我尝试通过chrome浏览器连接到服务器(http://127.0.0.1:8080)时,得到的页面上面写有:“此页面不起作用,本地主机发送了无效响应。ERR_INVALID_REDIRECT”并且它还会下载一个名为“ download”的文件。我不知道为什么会这样。这个“下载”文件与index.html文件中的代码几乎完全相同。代码如下:
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Testing pixi.JS</title>
<!-- The <script> tag's src should be relative to your root directory where your webserver is running -->
<script src="pixi/pixi.min.js"></script>
</head>
<body>
<script type="text/javascript">
let type = "WebGL";
if(!PIXI.utils.isWebGLSupported()){
type = "canvas";
}
</script>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
<!-- MY INDEX.HTML CODE -->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Testing pixi.JS</title>
<!-- The <script> tag's src should be relative to your root directory where your webserver is running -->
<script src="./pixi.min.js"></script>
</head>
<body>
<h1>Hello there!</h1>
<script type="text/javascript">
let type = "WebGL";
if(!PIXI.utils.isWebGLSupported()){
type = "canvas";
}
</script>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
移动到与INDEX.HTML相同的文件夹后,键入CMD的代码:
npm安装http-server -g
HTTP服务器
我希望页面能够加载,但事实并非如此。我不知道该怎么办。
If you navigate to the full path it seems to work: http://127.0.0.1:8080/index.html It seems to be some http-server bug.
There are many other local web servers. I suggest browsersync:
npm install -g browser-sync
browser-sync start --server --index index.html
Run Code Online (Sandbox Code Playgroud)
小智 5
有一个错误,它似乎只对 Windows 有影响。您应该安装较低版本的 http-server,0.9.0 可以工作。
运行以下命令
npm install -g http-server@0.9.0
Run Code Online (Sandbox Code Playgroud)
欲了解更多信息,请单击此处。