我正在开发一个 node.js 应用程序,它通过路由提供 index.ejs 页面。index.js(这是一条路线)
var express = require('express');
var router = express.Router();
/* GET home page. */
router.get('/', function(req, res) {
res.render('index', { title: 'Express', clicks: req.app.get('clicks')});
});
module.exports = router;
index.ejs 文件:
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>The HTML5 Herald</title>
<meta name="description" content="The HTML5 Herald">
<meta name="author" content="SitePoint">
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">
<link rel="stylesheet" href="/stylesheets/style.css">
</head>
<body>
<div class="container">
<h1>
<%=title%>
</h1>
<div class="page">
</div>
</div>
<!-- <template id="click-list-template">
<table class="table striped">
<thead>
<th>
<td>day</td>
<td>hour</td>
<td>minute</td>
<td>count</td>
</th>
</thead>
<tbody>
<% _.each(clicks, function(click){%>
<tr>
<td><%=click.get('day')%></td>
<td><%=click.get('hour')%></td>
<td><%=click.get('minute')%></td>
<td><%=click.get('count')%></td>
</tr>
<%});%>
</tbody>
</table>
</template> -->
<script>
var dash = {};
dash.clicks = <%=clicks%>
</script>
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/underscore.js/1.6.0/underscore-min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/backbone.js/1.1.2/backbone-min.js"></script>
<!-- <script src="/javascripts/index.js"></script> -->
<script src="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"></script>
</body>
</html>
直到最近它工作得很好。现在它只是不断抱怨styles.css 没有加载,而且'_' 是未定义的。但是,我从不同的目录加载 style.css,而不是它的抱怨,这在早期工作。现在不管我对 ejs 文件做了什么更改,包括将整个文件注释掉。它一直显示完全相同的错误。此外,我曾多次尝试重新启动服务器,但没有任何运气。
将不胜感激任何帮助。对我来说似乎是服务器端缓存问题,但不知道如何解决。我用谷歌搜索,但找不到任何东西,因此在这里发布。
提前致谢!