我能够从一个玉页发送数据到另一个,但我不知道如何在app.js的其他页面中使用它?(I am able to send a data from one jade page to other but I am not knowing how to use that in other page in app.js?)
我将变量'id'从索引页面发送到info / studs页面,它正在执行该部分,但我无法在app.js中使用该变量
extends layout block content .container .col-md-4 h2 Name a(href='../info/studs?id=#{user.id}') #{user.name} and app.js file containing app.get('/info/studs',function(req, res){ //Here I want to use variable 'id'});
I am sending the variable 'id' from index page to info/studs page, and it is doing that part,but I am not able to use that variable in app.js
extends layout block content .container .col-md-4 h2 Name a(href='../info/studs?id=#{user.id}') #{user.name} and app.js file containing app.get('/info/studs',function(req, res){ //Here I want to use variable 'id'});
最满意答案
查看req.query对象以获取更多信息。
要具体回答这个问题:
app.get('/info/studs',function(req, res){ //Here I want to use variable 'id' var id = req.query.id //You can now use the 'id' variable as you want. })Take a look into the req.query object for more information.
To specifically answer the question:
app.get('/info/studs',function(req, res){ //Here I want to use variable 'id' var id = req.query.id //You can now use the 'id' variable as you want. })更多推荐
发布评论