Express 快速路线参数在包含“"@&引用;
有一条非常简单的快速路线Express 快速路线参数在包含“"@&引用;,express,Express,有一条非常简单的快速路线 router.get('/compare/:packages', function(req, res, next) { const packages = req.params.packages.split(','); res.render('index', { title: "title" }); }); 当使用包含@符号的内容访问它时,它不匹配并返回404,帮助 /compare/elm,@cycle/run 编辑:这起作用了 router.get('/c
router.get('/compare/:packages', function(req, res, next) {
const packages = req.params.packages.split(',');
res.render('index', { title: "title" });
});
当使用包含@符号的内容访问它时,它不匹配并返回404,帮助
/compare/elm,@cycle/run
编辑:这起作用了
router.get('/compare/:packages*', function(req, res, next) {
const packages = req.params.packages.split(',');
res.render('index', { title: "title" });
});
问题不是
@
,而是/run
之前的/
,因为默认情况下,参数将由斜杠分隔
您可以使用以下选项:
router.get('/compare/*', function(req, res, next) {
const packages = req.params[0].split(',');
res.render('index', { title: "title" });
});
谢谢引导我走上正确的道路。添加尾随*修复了我的问题