Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
渲染视图(Expressjs 2.x)时我需要有不同的布局。如何改变它们? 例如:
res.render('follow_page', {layout:'layout_2'}, {name:'test'}) res.render('user_page', {layout:'layout_1'}, {user:'test1'})
对于 Express 2.x 及更早版本,您需要合并 2 个对象,并为其赋予一个locals属性:
locals
res.render('follow_page', { layout: 'layout_2', locals: { name: 'test' } }); res.render('user_page', { layout: 'layout_1', locals: { name: 'test1' } });