【发布时间】:2014-01-23 15:18:57
【问题描述】:
我的项目有一个小问题。 我正在为一个小网页使用 node 和 express .. 它正在呈现 html 页面,但是 javascript 文件(test.js)没有发送给用户..
<!doctype html>
<html>
<head>
<title>Spektrum</title>
<script src="test.js"></script>
<meta name = "viewport" content = "initial-scale = 1, user-scalable = no">
<style>
canvas{
}
</style>
</head>
<body>
<!-- some stuff -->
</body>
</html>
Node.js 文件:
var http = require('http'),
fs = require('fs'),
express = require('express'),
app = express();
app.use(express.bodyParser());
app.set('view engine', 'ejs');
app.engine('html', require('ejs').renderFile);
// .....
app.listen(8080, function() {
console.log('Server running at http://127.0.0.1:8080/');
});
知道如何将带有 html 文件的 javascript 文件发送给用户吗?
您好, JS
【问题讨论】:
-
您使用的是 Express 的静态中间件吗?如果没有,看看这个:expressjs.com/api.html#app.use
标签: javascript html node.js express