【问题标题】:expressjs - not able to load my stylus stylesheet to jade html pageexpressjs - 无法将我的手写笔样式表加载到玉 html 页面
【发布时间】: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


【解决方案1】:

手写笔中间件不应该从 /styles 获取源来将 dest 设置为 /styles 吗? :

app.use(stylus.middleware({
    debug : true,
    src : __dirname + '/styles',
    dest : __dirname + '/styles'
}));

【讨论】:

    猜你喜欢
    • 2015-02-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-10-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多