简体   繁体   English

Node.js 带参数的路由

[英]Node.js routes with parameters

My first time using Node.js/express routes, I cannot match when I use parameters我第一次使用Node.js/express路由,使用参数时无法匹配

<a href="/produtos/1/produto-test">

 app.use('/produtos', produtosRouter);

//below the produtosRouter, function
router.get('/', function(req, res, next) {
  res.render('produtos/:id/:slug', { title: 'test test.' });
});

Does this help?这有帮助吗?

router.get('/:id/:slug', function(req, res, next){
  res.render('<name_of_the_template>', { title: 'test test.'});
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM