为什么无法获取layout.jade
发布于 10 年前 作者 384324085 4379 次浏览 最后一次编辑是 8 年前

app.js里的内容 app.get(’/tasks’,function(req,res){ Task.find({},function(err,docs){ res.render(‘tasks/index’,{ title: ‘Todo index view’, docs: docs }); }); }); 目录结构 -views –tasks —index.jade –layout.jade 在render中不写layout配置,默认不是调用layout的么。 layout.jade内容 html head title= title link(href=‘stylesheets/bootstrap.min.css’,type=‘text/css’,rel=‘stylesheet’) body section.container

8 回复

你的express是不是3.0以后的版本的,新版本的都不支持layout了,坛子里面有介绍,你找找看

自定义的layout也不支持?那如何处理公共页部分,css和js,请教了

貌似,layout是引入了,但是我的index.jade的内容没有预期写入section标签中。整个页面只有layout的html代码,没有index.jade的代码

@thesadboy 我懂你意思了,对于CSS,js可以用extends,对于头尾,导航之类,用include,是这样么

@thesadboy 试过了,extends好像整个页面照搬,我改用include,就好了。

@thesadboy 先谢谢了,再弱弱地问个问题,如果jade页面多了,每次页面都要写include,很麻烦,有其他方式么?

@thesadboy 我的意思是index.jade会引入layout.jade里的内容去覆盖自己。

@thesadboy 我在index.jade上写了,layout.jade也需要写么?

回到顶部