【问题标题】:Can't include scripts/css on AppFog Node App不能在 AppFog 节点应用程序上包含脚本/css
【发布时间】:2014-12-12 20:53:32
【问题描述】:

我正在尝试使用 AppFog 创建一个 Node 应用程序,我首先将 index.html 包含在我的 app.js

var http = require('http'),
fs = require('fs');


fs.readFile('./index.html', function (err, html) {
    if (err) {
        throw err; 
    }       
    http.createServer(function(request, response) {  
        response.writeHeader(200, {"Content-Type": "text/html"});  
        response.write(html);  
        response.end();  
    }).listen(8000);
});

然后索引包括脚本和 css

<!-- jQuery -->
<script src="script/jquery-2.1.1.min.js" type="text/javascript"></script>
<script src="base.js" type="text/javascript"></script>
<!-- Bootstrap -->
<script src="Bootstrap/js/bootstrap.min.js" type="text/javascript"></script>
<link rel="stylesheet" href="Bootstrap/css/bootstrap.min.css">
<link rel="stylesheet" href="Bootstrap/css/bootstrap-theme.min.css">
<!-- Main CSS -->
<link rel="stylesheet" href="main.css">

index.html 正在正确加载,但脚本和样式却没有。 该站点是THIS,如果您要查看,从控制台可以看到每个文件都返回 index.html 而不是 JS 代码或 CSS 样式。

【问题讨论】:

    标签: javascript css node.js include appfog


    【解决方案1】:

    我通过使用 Express NodeJS 框架解决了这个问题,并让他将用户重定向到正确的页面。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-09-12
      • 1970-01-01
      • 2013-10-07
      • 2013-01-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多