【问题标题】:Router.go() does not working when adding extra path添加额外路径时,Router.go() 不起作用
【发布时间】:2017-01-01 10:05:48
【问题描述】:

我已经像这样在我的 router.js 中创建了路由器:

Router.go("students/add/:id?", {
    name:"students",
    progress: {
        enabled: false
    },
    fastRender: true
});

在我的添加新学生页面中,我的提交事件中有此代码以重定向到编辑模式页面

Router.go("students/add/" + studentId);

但这不起作用。它不会重定向到编辑页面。有什么想法吗?

【问题讨论】:

  • 不应该是Router.go("/students/add/" + studentId);吗?
  • @pahan 很奇怪。它正在工作!
  • 添加斜线有什么用?
  • @pahan 是的,添加一个斜线就可以了。

标签: meteor iron-router router


【解决方案1】:

在 Iron 路由器中编写 router.go 的好方法是:

Router.go('post.show', {_id: 1}, {query: 'q=s', hash: 'hashFrag'});

所以你的 Router.go 会是这样的

Router.go('students', {id?:studentId});

【讨论】:

    【解决方案2】:

    应该是Router.go("/students/add/" + studentId);(带斜线)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-11-02
      • 1970-01-01
      • 2012-11-27
      • 1970-01-01
      • 2012-07-05
      • 1970-01-01
      • 1970-01-01
      • 2021-03-03
      相关资源
      最近更新 更多