【发布时间】:2018-06-16 04:58:00
【问题描述】:
这是在我的 node.js 脚本文件中获取文件的代码。
app.get('/',function(req,res){
app.use(express.static(__dirname));
res.sendFile(path.join(__dirname+'/Login.html'));
res.sendFile(path.join(__dirname+'/View.html'));
res.sendFile(path.join(__dirname+'/Setup.html'));
});
有一段时间我的代码运行良好,一切运行顺利。然后我的html文件开始被切断。例如 login.html 是我的 index html,它有 250 行,在 locahost 中运行后,很多按钮都坏了。我用 f11 检查了源代码,它只显示了 215 行。
这是一个例子: 记事本++:https://i.imgur.com/hyqi03t.png
本地主机:https://i.imgur.com/VI6eurr.png
此外,localhost 仅加载 6 个文件中的 4 个。刷新后,经常显示错误的页面为 index.html 或仅加载 6 个文件中的 1 个。 https://i.imgur.com/kHjR7XF.png
这个网站运行了一段时间,在我回滚了几个版本后,它甚至似乎无法正常运行。
我在 Console.log 中得到的错误是 Error: Can't set header after they're sent.
【问题讨论】:
标签: javascript html node.js express