如何让route.get获取到当前url的参数id值?
我的代码如下,请问可以在route里直接获取url的id值吗? 如果不行,应该怎么做 求助!!!!! html中:
-
<a href="#/admin/sharepass/<%=share.id%>">审核
js中:
-
var adminsharepass = {
-
url:"/admin/sharepass/:id",
-
class:"adminsharepass",
-
render: function (){
-
return $._ajax({
-
url:"/admin/sharepass/:id",
-
type:"get"
-
});
-
}
route中:
-
router.get('/sharepass/:id', function(req, res, next) {
-
let sql = "select*from share WHERE id=?";
-
util.getConn().queryAsync(sql,[req.param('id')]).then((result)=>{
-
res.render("admin/adminsharepass.html",{share:result});
-
}).catch((err)=>{
-
res.send("error");
-
})
-
});
1 回复
req.params