假设我有ApplicationRoute
一个操作goBack
(正如您在评论中看到的,由于不同移动浏览器中的错误,我需要自己处理 goBack):
Mobile.ApplicationRoute = Em.Route.extend
actions:
goBack: ->
# TODO: Remove when iOS 7 fixed their history
# If there's no route to go back, go to front
# TODO: Remove when Microsoft fixed their
# back button in offline mode
if not (Nn.MobileHelper.isiPhone() or Nn.MobileHelper.isIeMobile()) and @get("router.recentRoute")?
return window.history.back()
@get("controller").set("isHitBackButton", true)
@transitionTo("front").then => @get("controller").set("isHitBackButton", false)
如何从另一条路线触发此操作?请注意,由于我需要调用@transitionTo
,因此这段代码必须在路由内。