1
如何在EmberJS中的初始化程序中獲取位置類型? 我們假設我將config的locationType設置爲auto
。我想知道,當應用程序運行時,在初始化程序中,是否使用哈希或歷史記錄。Ember.js在運行時獲取位置類型
我可以這樣做嗎? 謝謝。
如何在EmberJS中的初始化程序中獲取位置類型? 我們假設我將config的locationType設置爲auto
。我想知道,當應用程序運行時,在初始化程序中,是否使用哈希或歷史記錄。Ember.js在運行時獲取位置類型
我可以這樣做嗎? 謝謝。
它花了一些時間,但你可以查找附加到路由器的位置,並將其與相關案例進行比較。
const hashLocation = this.container.lookup('location:hash');
const historyLocation = this.container.lookup('location:history');
const currentLocation = this.container.lookup('router:main').get('location');
if(hashLocation === currentLocation){
// Do thing
}else if(historyLocation === currentLocation) {
// Do other thing
}else{
// Fail whale.
}