Ember.js在运行时获取位置类型
在EmberJS中,如何在初始值设定项中获取位置类型? 假设我在config中将locationType设置为Ember.js在运行时获取位置类型,ember.js,browser-history,hashtag,Ember.js,Browser History,Hashtag,在EmberJS中,如何在初始值设定项中获取位置类型? 假设我在config中将locationType设置为auto。我想知道,当应用程序运行时,在初始值设定项中,是否正在使用哈希或历史记录 我能做这个吗? 谢谢。这花了一些时间,但您可以查找连接到路由器的位置,并将其与相关案例进行比较 const hashLocation = this.container.lookup('location:hash'); const historyLocation = this.container.looku
auto
。我想知道,当应用程序运行时,在初始值设定项中,是否正在使用哈希或历史记录
我能做这个吗?
谢谢。这花了一些时间,但您可以查找连接到路由器的位置,并将其与相关案例进行比较
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.
}