我在我的项目中使用express-ejs-layout。我的项目有路由。我想为不同的 res 查询使用不同的布局。例如,如果查询是:www.xxx.com/a,则使用 LayoutA.ejs,如果查询是:www.xxx.com/b,则使用 LayoutB.ejs。我的 index.js 部分代码是:
...
app.set('view engine', 'ejs');
app.set('views', path.join(__dirname, '/app_server/views'));
app.use(bodyParser.urlencoded({ extended: false }));
app.use(bodyParser.json());
app.use(ejsLayout);
app.use('/public', express.static(path.join(__dirname, 'public')));
require('./app_server/routes/routeManager')(app);
...
Run Code Online (Sandbox Code Playgroud)
我怎样才能?