Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/windows-phone-7/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Express 快速路线参数在包含“"@&引用;_Express - Fatal编程技术网

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" });
});

谢谢引导我走上正确的道路。添加尾随*修复了我的问题