节点js服务器未加载我的网站文件 [英] The node js server is not loading my website files
本文介绍了节点js服务器未加载我的网站文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当我运行节点index.js时,浏览器只加载html,忽略javascript,images和css,如果我尝试访问链接,则会显示一个空白的plage:node.js无法获取/login.html,如何我能解决这个问题吗?
When I run node index.js the browser loads only the html, disregarding javascript, images, and css , and if I try to access a link it shows a blank plage: node.js Cannot GET /login.html, how do I fix that?
var app = require('express')();
var http = require('http').Server(app);
var io = require('socket.io')(http);
var myList = new Array();
var i = 0;
app.get('/', function(req, res){
res.sendFile(__dirname + '/index.html', {});
});
推荐答案
您需要在问题中显示错误并且/ login.html文件?
You need show the error with your question and "/login.html" file?
或快速修复,您可以更改以下代码:
Or quick-fix, you can change your code as below:
res.sendFile(__dirname + '/index.html', {});
到
res.render('index.html', { /*data*/ });
这篇关于节点js服务器未加载我的网站文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文