![](/img/trans.png)
[英]Can an Ember component listen for a route's didTransition action?
[英]How can you listen to ember route changes?
如何在余燼應用程序外部檢測路線更改(#或popstate)? 我已經嘗試過了,但是沒有運氣:他們從不開火
window.onhashchange = function locationHashChanged() {
console.log(location.hash);
};
window.addEventListener('popstate', function locationHashChanged(e) {
console.log(e.location);
});
我不確定100%是否有公共API中執行此操作的好方法。 但是,如果您覺得有些棘手,可以使用此處描述的屬性。
var applicationController = App.__container__.lookup('controller:application');
applicationController.addObserver('currentRouteName', function() {
var currentRouteName = applicationController.get('currentRouteName');
// ...
});
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.