Does Ember routing fall back to using a hash if browser doesn't support the History API?

主宰稳场 提交于 2019-12-18 04:09:31

问题


Ember documentation states that it can be set to use the History API for routing rather than hash-based fragments by using:

App.Router.reopen({
  location: 'history'
});

But I can find no mention of what will happen if a browser doesn't support the History API. Will it fall back to using a hash like History.js?

If not, should I check for History API support and switch history implementation to hash if it isn't supported?


回答1:


There doesn't seem to be any History API support detection in the ember source.

So if you set location to history, and there's no support, your routing will probably fail.

If you intend to support old browsers, safest bet is like you said:

if (window.history && window.history.pushState) {
    App.Router.reopen({
      location: 'history'
    });
}

UPDATE 23 Jan 2014

You can now use location:'auto' if you enable ember-routing-auto-location feature in canary.



来源:https://stackoverflow.com/questions/15056877/does-ember-routing-fall-back-to-using-a-hash-if-browser-doesnt-support-the-hist

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!