如果浏览器不支持History API,Ember路由是否会返回使用哈希? [英] Does Ember routing fall back to using a hash if browser doesn't support the History API?

查看:113
本文介绍了如果浏览器不支持History API,Ember路由是否会返回使用哈希?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Ember文档状态可将其设置为使用History API进行路由通过使用以下方式的基于散列的片段:

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'
});

但是,如果浏览器不支持History API,我可以找不到任何提示。是否会回退使用像History.js这样的哈希?

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?

如果没有,如果不支持,我应该检查历史API支持并将历史记录实现切换到哈希?

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

推荐答案

在ember源中似乎没有任何历史API支持检测。

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'
    });
}



更新2014年1月23日



您现在可以使用位置:'auto'如果您启用了 ember-routing-auto-location 功能金丝雀。

UPDATE 23 Jan 2014

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

这篇关于如果浏览器不支持History API,Ember路由是否会返回使用哈希?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆