How do you go to the previous route in iron-router?

家住魔仙堡 提交于 2019-12-12 10:57:13

问题


I'm using an event handler to go to the previous URL/route:

'click #back': ->
  history.back()

This works in Chrome desktop, Chrome devtools mobile device view, and in Safari on a physical device itself (iOS 8.1.2), but not in Chrome on the device. Behavior is:

  • Load /
  • Click link to /foo
  • URL changes to /foo, and foo template renders
  • Click #back
  • URL changes to / briefly, then changes back to /foo. The page body does not change. (Correct behavior is the URL permanently changes to /, and the / templates are rendered, without a page load.)
  • Click #back second time
  • / is reloaded from server

Is this a mobile Chrome problem, or should I be using some iron-router API like Router.back()?


回答1:


history.back() is the method supported by iron-router, it just appears there's a problem with iOS Chrome.



来源:https://stackoverflow.com/questions/27455173/how-do-you-go-to-the-previous-route-in-iron-router

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!