如何使用多个参数创建路线?
问题描述:
我使用所谓quickWallet支付系统,它被重定向到以下网址我的应用程序:如何使用多个参数创建路线?
http://localhost:3000/payment-response?status=failed&id=1009891&billnumbers=1480072195&checksum=2fcdb781a18f795459b3f388135419eeae02dda12da05e2613eae8ce4f16e514
如何使用它我FlowRouter处理?
这是我目前的路由定义:
FlowRouter.route('/payment-response?',{
name:'payment Response Received',
action(){
BlazeLayout.render('paymentResponse');
}
});
我得到我的控制台下输入如下:?
kadira_flow-router.js哈希= 9cd2691 ...:519没有路由的路径:/付款响应状态=失败& ID = 1009891个& billnumbers = 1480072195 &校验= 2fcdb781a18f795459b3f388135419eeae02dda12da05e2613eae8ce4f16e514
我在做什么错了?
答
定义不使用问号的路径,因为它只是表示URL的查询部分的标记。
作为FlowRouter的first example所示:
FlowRouter.route('/blog/:postId', {
action: function(params, queryParams) {
console.log("Yeah! We are on the post:", params.postId);
}
});
查询参数是可作为action()
方法的第二个参数。
因此,代码应该是这样的:
FlowRouter.route('/payment-response',{
name: 'paymentResponseReceived',
action(_params, queryParams){
// render your layout with the queryParams
}
});
感谢好友为我工作。我可以通过queryParams.status或queryParams.id访问各个参数。 – Rashmi