express框架使用了layout.html模板(ejs引擎), 例如在进行网站首页展示时采用
res.render('index',{ layout:'layout.html', title:'首页' });
在渲染用户中心时采用
res.render('user',{ layout:'layout.html', title:'个人中心' });
layout.html内容结构如下
现在问题是,每个页面都使用layout.html模板,但不同的页面加载的css和js各不相同; index加载了index.css, index.js; 在加载首页时,layout引用了index.css 当加载user页面时user.css如何引入到视图中?或者其他方式解决? nodeclub代码layout文件加载了所有静态文件,不可能每个页面都会用到吧? 还请社区前辈帮助解答,谢谢!