【发布时间】:2014-01-05 06:28:26
【问题描述】:
在我的快速应用程序中,我正在尝试从样式模块引擎加载样式属性。但我根本无法加载我的样式。
这是我的文件夹结构:
我的节点应用程序
-node_modules
-styles
-style.css
-style.styl
-views
-index.jade
这是我使用手写笔调用的 app.js 代码。
var http = require("http"),
express = require("express"),
stylus = require("stylus"),
app = express();
app.set('view engine', 'jade');
app.set('views', './views');
app.use(stylus.middleware({
debug : true,
src : __dirname + '/views',
dest : __dirname + '/styles'
}));
app.use(express.static(__dirname + '/styles'));
app.use(express.static(__dirname + '/css'));
app.get('/', function (req, res, next){
res.end("<h1>Sample Tittle</h1>");
next();
});
app.get("/sample", function(req, res) {
res.render('index');
})
app.listen(1337);
但是根本没有渲染和应用到我的玉文件。
这是我的 'index.jade' - 文件
html
head
title welcome to Jade!
link(rel='stylesheet', href='style.css')
body
h1 Test title
这里出了什么问题,如何解决?
【问题讨论】:
-
您的代码对我有用。仔细检查您的文件夹结构和文件。
标签: html node.js express stylus