簡體   English   中英

如何從全球背景過渡到Ember路線?

[英]How to transition to route in Ember from global context?

我正在將chrome擴展程序與ember應用程序集成。 我的app.js文件中有一些chrome擴展代碼:

window.sendToExtension = (message, callback) => {
  chrome.runtime.sendMessage(extensionId, message, (response) => {
    console.log('got response from extension!!', response)
    if (response.path) {
      //Here I need to tell the ember app the transition to the given path
    }
  })
}

this是指window所以我不能只調用this.transitionTo 如何轉換為擴展程序告訴我的路線名稱?

我想到了!! 我要做的就是在執行window.applicationRouteInstance = this的應用程序路由上添加一個beforeModel鈎子,然后可以全局訪問該代碼,例如在我的擴展消息傳遞代碼中,以執行applicationRouteInstance.transitionTo(response.path)

另外還有2.3版中的新App.visit API

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM