路由和用铁路由器重定向 [英] Routing & redirecting with iron-router

查看:52
本文介绍了路由和用铁路由器重定向的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

一个人如何使用流星和Iron-Router从Template.event调用中将官方重定向到另一条路线.我似乎至少在Dev分支遇到相同的错误

How does one do an official redirect to another route from a Template.event call using meteor and Iron-Router. I seem to, at least with the Dev branch run into the same error

`if (this._isRunning)                                                                                        // 174
      throw new Error('Already in a page run'); `

作为一个例子,我有一个按钮,如果我运行它,它会在单击时调用Router.go('/home');,我会收到已经在页面运行中"错误.还有其他使用router go方法进行路由的人吗?

As an example, i have a button that on click calls Router.go('/home'); if i run this, i get the 'already in a page run' error. Anyone else routing with the router go method?

实际上是导致问题的'this.redirect('/anotherpath')'.有没有办法停止当前正在运行的页面运行并重定向到其他路由?

Its actually the 'this.redirect('/anotherpath')' that causes the problem. Is there way to stop the current running page run and redirect to another route?

推荐答案

似乎您正在使用dev分支.您正在使用的代码已回滚,因为它无法正常工作.如果您仍然遇到问题,请告诉我,对此表示抱歉!

It looks like you're working off of the dev branch. The code you were working with has been rolled back because it wasn't working properly. If you still have the issue let me know, and sorry about that!

下面的代码将停止当前路由控制器的运行(停止运行任何下游钩子和action方法),并调用Router.go('/anotherpath'),这将导致新路由的运行.

The code below will stop the current route controller from running (stop any downstream hooks and the action method from being run) and call Router.go('/anotherpath') which will cause a new route to run.

this.redirect('/anotherpath')

这篇关于路由和用铁路由器重定向的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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