加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

IE9 PathLocationStrategy Angular 4

发布时间:2020-12-17 10:25:09 所属栏目:安全 来源:网络整理
导读:我正在使用IE9和PathLocationStrategy与Angular4但它似乎没有工作.它只是附加“#”无限时间.我尝试添加history.js polyfill,但似乎没有任何工作. 任何人都可以帮助我如何使用PathLocationStrategy与Angular 4和IE9? 更新: 我终于想通了,我们不能在IE9上使
我正在使用IE9和PathLocationStrategy与Angular4但它似乎没有工作.它只是附加“#”无限时间.我尝试添加history.js polyfill,但似乎没有任何工作.

任何人都可以帮助我如何使用PathLocationStrategy与Angular 4和IE9?

更新:
我终于想通了,我们不能在IE9上使用PathLocationStrategy.现在我想弄清楚如何在浏览器的其余部分使用PathLocationStrategy,只有当IE9存在时,切换到HashLocationStrategy.
我试图在我的模块中包含以下代码行:

RouterModule.forRoot(COMMON_ROUTES,{ useHash: !Boolean(history.pushState) }),

我验证了,!Boolean(history.pushState)在IE9中返回true,在其余浏览器中返回false.但它没有用.即使在IE9中,Angular默认为PathLocationStrategy.有人可以帮忙吗?

原因

Older browsers [non-evergreen] send page requests to the server when the location URL changes unless the change occurs after a “#” (called the “hash”). Routers can take advantage of this exception by composing in-application route URLs with hashes.

解决方案

遗憾的是没有解决方案……

如documentation中所述,HashLocationStrategy在引导过程中启动.

… You can switch to the HashLocationStrategy with an override during the bootstrapping process if you prefer it.

这进一步加强了……

You must choose a strategy and you need to make the right call early in the project. It won’t be easy to change later once the application is in production and there are lots of application URL references in the wild.

即,您需要开发内容以使用特定的位置策略,并且更改策略意味着您必须在开发期间更新重要的逻辑和其他路由功能,而不是像您希望的那样在后期思考/运行时.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读