当前位置:网站首页>Use of pathinfo/pathname in nodejs

Use of pathinfo/pathname in nodejs

2022-06-23 21:07:00 henu_ Newxc03

pathinfo/pathname The style parameters are as follows : for example : /detail/1/economy (detail/:id/:type)

<h1> This is the list page </h1>
<hr>
<ul>
    <li><a href="/detail/1"> The first 1 News headlines </a></li>
    <li><a href="/detail/2"> The first 2 News headlines </a></li>
    <li><a href="/detail/3"> The first 3 News headlines </a></li>
    <li><a href="/detail/4"> The first 4 News headlines </a></li>
</ul>

Interface :

app.get("/list", (req,res)=>{
    
    res.render("list")
})

app.get("/detail/:id", (req,res)=>{
    
    console.log(req.params);
    //let {id, type} = req.params;   //  Deconstruct to get multiple 
    //console.log(id, type);

    res.send(" detail ok! ");
    
})

原网站

版权声明
本文为[henu_ Newxc03]所创,转载请带上原文链接,感谢
https://yzsam.com/2021/12/202112261502154106.html