【问题标题】:How to get parameter from previous template into current template's helper method如何从以前的模板中获取参数到当前模板的辅助方法中
【发布时间】:2017-05-19 20:53:00
【问题描述】:

我正在使用 Meteor + FlowRouters。

假设我有 2 页产品付款。用户从 Products 页面选择产品(我们将“_id”存储为隐藏字段)并重定向到 Payments

场景:

产品页面(_id as 'queryparam') ---------> 支付页面(如何在这里获取助手中的_id? )

问题:

在付款页面,我想显示我们从产品页面传递的“_id”中的产品详细信息,作为结帐信息。我想在 Payments 的辅助方法中获取参数,该怎么做?

【问题讨论】:

  • 你使用什么路由机制?如果您使用的是 Iron 路由器,则可以将 id 作为 URL 中的可选/强制参数之一发送..
  • 我正在使用流路由。
  • 流路由器中应该也有类似的东西。让我快速浏览一下
  • 我正在从以前的模板助手传递 queryParam。我只是想在当前模板助手中以某种方式使用相同的参数。
  • 请阅读文档,那里有完美的解释github.com/kadirahq/flow-router#flowroutergetparamparamname

标签: meteor meteor-blaze


【解决方案1】:

在我的付款页面中

Payments.html

<template name="App_Payments">
  <div>
    {{id}}
  </div>
</template>

Payments.js

import './Payments.html';

Template.App_Payments.helpers({
      id() {
       // below "id" is passed from Products page.
        return  FlowRouter.getQueryParam("id");
      }
});

【讨论】:

    猜你喜欢
    • 2019-09-04
    • 2015-03-13
    • 2012-06-24
    • 1970-01-01
    • 2017-10-22
    • 2015-01-07
    • 1970-01-01
    • 2011-03-15
    相关资源
    最近更新 更多