1
从我所知道的文档,我可以把我的快递4.12.x使用多个视图目录如下:NodeJS Express:用于不同视图目录的不同URL?
app.set('views', [
__dirname + '/views1',
__dirname + '/views2'
]);
但我想有不同的URL会从不同的观点目录的看法。所以我想做某事,如:
app.get('/views1/:view', function (req, res) {
res.render(req.params.view); //get the views only from /views1
});
app.get('/views2/:view', function (req, res) {
res.render(req.params.view); //get the views only from /views2
});
此刻会出现什么情况是,快递总是在/views1
检查:view
,然后在/views2
,无论相应的URL。我知道这是Express的正常行为,但我很想知道是否有可能让我的想法奏效。