【问题标题】:BaseURL in Ember CLI application with IE9 support支持 IE9 的 Ember CLI 应用程序中的 BaseURL
【发布时间】:2014-07-14 08:58:05
【问题描述】:

对于我的 Ember CLI 应用程序,我想使用 baseURL,如 here 所述。它适用于 History API,但对于旧的 Hash API,它不会按预期工作。

我的配置:

module.exports = function(environment) {
    var ENV = {
        environment: environment,
        baseURL: '/base/',
        locationType: 'auto',
        ...
    };

    ...

    return ENV;
}

在 IE9 中,我得到了 localhost:4200/#/base/login 而不是 localhost:4200/base#/login。手动转到此页面会导致空白(白色)页面。

【问题讨论】:

    标签: ember.js ember-cli


    【解决方案1】:

    我发现你必须设置路由器 rootUrl 以及环境 baseUrl。

    //router.js
    import Ember from 'ember';
    import config from './config/environment';
    
    let Router = Ember.Router.extend({
      location: config.locationType,
      rootURL: config.baseURL
    });
    
    export default Router;
    

    【讨论】:

      【解决方案2】:

      显然这是一个已知问题:http://github.com/stefanpenner/ember-cli/issues/417

      【讨论】:

      • 抱歉忘了提及我已经使用了 location: 'auto' 属性。更改了我的问题以包含此(尽管 Ember CLI 调用此属性 locationType)
      • 知道了,但你不能在 ie 上改变这种行为,因为这是不支持历史 API 的后备。
      • 我不想改变行为。在最后一行中,我提到 IE9 的链接/结果错误。但该链接使用哈希 API。所以这很好(较新的浏览器确实使用 History API,这些浏览器运行良好)。只是在 IE9 中它没有正确设置基本 url ==> 现在:root#/base/path;我想要:root/base#/path
      • 这显然是一个已知问题:github.com/stefanpenner/ember-cli/issues/417
      • 谢谢,看来我得等到它修好。回答这个问题,你会得到奖励:)
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-11-07
      • 2014-08-30
      • 1970-01-01
      • 2014-11-10
      • 1970-01-01
      相关资源
      最近更新 更多