我正在创建一个带有节点的 http 服务器,它读取一个简单的 html 文件。这个 html 文件导入了一些位于我的计算机中的脚本。节点无法加载此脚本。为什么?
var http = require('http');
var io = require('socket.io').listen(2210);
var fs = require('fs');
http.createServer(function(req, res){
fs.readFile("./index.html", function(err, data){
if (err){
res.writeHead(500);
res.end("Error loading index.html");
}
res.writeHead(200, {"Content-Type":"text/html"});
res.end(data, 'utf-8');
});
}).listen(2211);
io.sockets.on('connection', function(socket){
});
这是html文件:
<!DOCTYPE html>
<html>
<head>
<title>ASGEAWER</title>
<meta name="viewport" content="width=device-width, minimum-scale=1, maximum-scale=1">
<link rel="stylesheet" href="jquery-mobile/jquery.mobile.css" />
<link rel="stylesheet" href="jquery.mobile.splitview.css" />
<link rel="stylesheet" href="jquery.mobile.grids.collapsible.css" />
<script type="text/javascript" src="jquery-1.7.1.js"></script>
<script type="text/javascript" src="jquery.mobile.splitview.js"></script>
<script type="text/javascript" src="jquery.mobile.js"></script>
<script type="text/javascript" src="servernode.js"></script>
<script type="text/javascript" src="interaction.js"></script>
<script type="text/javascript">
$(document).on("ready",inici);
</script>
</head>
<body>
<div data-role="panel" data-id="menu" data-hash="crumbs" data-context="a#default">
<!-- Start of first page -->
<div data-role="page" id="main" data-hash="false">
<div data-role="header" data-position="fixed">
<h1>Categoria</h1>
</div><!-- /header -->
<div data-role="content">
<ul data-role="listview">
</ul>
</div>
</div><!-- /page -->
</div><!-- panel menu -->
<div data-role="panel" data-id="main">
<!-- Start of 6th page -->
<div data-role="page" id="aboutsv">
<div data-role="header" data-theme="b">
<h1>Productos</h1>
</div><!-- /header -->
<div data-role="content">
</div><!-- /content -->
</div><!-- /page -->
</div><!-- panel main -->
</body>
</html>
chrome 给了我这些错误:
Uncaught SyntaxError: Unexpected token < jquery-1.7.1.js:1
Uncaught SyntaxError: Unexpected token < jquery.mobile.splitview.js:1
Uncaught SyntaxError: Unexpected token < jquery.mobile.js:1
Uncaught SyntaxError: Unexpected token < servernode.js:1
Uncaught SyntaxError: Unexpected token < interaction.js:1
Uncaught ReferenceError: $ is not defined