expressjs - 无法将我的手写笔样式表加载到jade html页面 [英] expressjs - not able to load my stylus stylesheet to jade html page
问题描述
在我的快车应用程序中,我试图从样式模块引擎加载样式属性。但是我根本无法加载我的样式。
这是我的文件夹结构:
myNodeApp
-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();
});
$ b app.get(/ sample,function(req,res){
res.render('index');
})
app.listen(1337);
但是没有任何东西被呈现并应用到我的jade文件中。
这里是我的'index.jade' - file
html
头部
标题欢迎来到Jade!
link(rel ='stylesheet',href ='style.css')
body
h1测试标题
这里有什么问题,以及如何解决它?
不应该手写笔中间件从/ styles中获取源以将dest设置为/ style? :
$ b
app.use(stylus.middleware({
debug:true,
src:__dirname + '/ styles',
dest:__dirname +'/ styles'
}));
In my express app, i am trying to load the style properties from styles module engine. But i couldn't able to load my style at all.
here is my folder structure:
myNodeApp
-node_modules
-styles
-style.css
-style.styl
-views
-index.jade
and here is my app.js code where i call use the stylus.
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);
But nothing is rendered and applied to my jade file at all.
here is my 'index.jade' - file
html
head
title welcome to Jade!
link(rel='stylesheet', href='style.css')
body
h1 Test title
what is wrong here, and how to solve it?
Shouldn't the stylus middleware get the source from /styles to set the dest to /styles as well ? :
app.use(stylus.middleware({
debug : true,
src : __dirname + '/styles',
dest : __dirname + '/styles'
}));
这篇关于expressjs - 无法将我的手写笔样式表加载到jade html页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!