使用玉器中的参数从一页路由到另一页 [英] Routing with parameters in jade from one page to another

查看:30
本文介绍了使用玉器中的参数从一页路由到另一页的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

由于我是NodeJS和Express的新手,因此在这里我需要一些帮助来解决我的问题.我在页面track.jade的页面上有table(jade),其中包含信息,并且带有"ID"链接到另一个页面.我可以成功地路由到另一个页面.但是我需要将参数从表"track.jade"传递到表中的另一页.

As i am new to nodejs and express, i would need some help here which could solve my problem. I have table(jade) on the page track.jade which contains information, with "ID" linking to another page. Successfully i can route to another page. But i need to pass the parameters from the table "track.jade" to another page within the table.

我该如何实现?因为我找不到任何可以确定此问题的文章.

How can i achieve this? as i am not able find any article which could determine this issue.

    mixin session(AWB_NO, Product_Name, PCS, Weight, Gross_Weight, DOP, DOE)
tr
td.session(data-sort-value="#{session_name}")
.flex.sm
div
a.name(href="/track/dist.jade") #{AWB_NO}
div
td.min(data-label="Name") #{Product_Name}
td.min(data-label="file") #{PCS}
td.min(data-label="s_name") #{Weight}
td.min(data-label="r_name") #{Gross_Weight}
td.min(data-label="Date") #{DOP}
td.min(data-label="Date") #{DOE}
td.remove
a.btn-remove
img(src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/5102/remove.svg", alt="Remove Session")
span Remove 
.container
.event-registration.reset
.content.wide
.row-inset
table.table-default.table-striped.table-bordered.sortable
thead(data-header="true")
tr
th(data-sort-column="true") AWB NO
th(data-sort-column="true") Product Name
th(data-sort-column="true") PCS
th(data-sort-column="true") Weight
th(data-sort-column="true") Gross Weight
th(data-sort-column="true") Date of Packing
th(data-sort-column="true") Date of Expiry
// th(data-sort-column="true") DOR
th
tbody(data-body="true")
+session("16783","Tuna Super","10","12,6","13","03/28/2017","04/28/2017")
+session("17670936423","Fresh Sword Fish","1","12,8","13,6","03/28/2017","04/28/2017")
+session("178529","Fresh Fish","8","10","11","03/28/2017","04/28/2017")
+session("16254","Baramundi","5","11","12","03/28/2017","04/28/2017")

我曾尝试使用url:localhost/3000/track/dist.jade从一个页面路由到另一页面

i had tried routing from one page to another page with the url localhost:3000/track/dist.jade

推荐答案

您需要将href值更改为快速路由器中设置的路由.然后可以在dist路由中将参数作为请求参数接收.

You need to change the href value to the route set in the express router. The parameter can then be received in the dist route as a request param.

track.jade

track.jade

a.name(href="/dist/" + AWB_NO ) #{AWB_NO}

dist.js

router.get('/dist/:awb', ensureLoggedIn, utils.checkAdmin, function (req, res, next) {
    res.render('dist',{
        AWB_NO: req.params.awb
    })    
});

这篇关于使用玉器中的参数从一页路由到另一页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆