【发布时间】:2015-08-30 21:45:45
【问题描述】:
我正在尝试设置一些动态路由,从所选链接中提取值并将其传递到我的路由中,然后放在下一页的名称之前。例如:
我在'/' 上有一个链接,然后点击一个链接<a href="#" id="solid-choice">Solid</a>
我想把这个链接值传入到下一页渲染的路由中。点赞'/solid/next-page'
我设置了一些路由,但我认为它没有按照我想要的方式正确地拉动路由。 /:pattern/next-page 是我特别说的路线
这是我的看法:
<!DOCTYPE html>
<head>
{{> head}}
</head>
<body class="pattern-wrapper">
{{> navigation}}
<div class="container">
<div class="row pattern-choice">
<div class="col-md-12">
<h2><i>Choose a pattern</i></h2>
<ul>
<li class="button-border">
<h3 class="button-choice" ><a href=":pattern/next-page" class="button-link" id="solid-choice">SOLID</a></h3>
</li>
<li class="button-border">
<h3 class="button-choice" id="stripe-choice"><a href=":pattern/next-page" class="button-link" id="stripe-choice">STRIPE</a></h3>
</li>
<li class="button-border">
<h3 class="button-choice" id="plaid-choice"><a href=":pattern/next-page" class="button-link" id="plaid-choice">PLAID</a></h3>
</li>
</ul>
</div>
</div>
</div>
</body>
</html>
这是我目前的路线:
var express = require('express');
var router = express.Router();
router.get('/', function(req, res){
res.render('pages/index.hbs');
});
router.get(':pattern/next-page', function(req, res){
req.param('pattern');
res.render('pages/color.hbs');
});
router.get('/suit-result', function(req, res){
res.render('pages/suit-result.hbs');
});
module.exports = router;
【问题讨论】: