Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angular/30.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angular 角度2路由在IE9中添加锚_Angular_Internet Explorer 9_Angular2 Routing - Fatal编程技术网

Angular 角度2路由在IE9中添加锚

Angular 角度2路由在IE9中添加锚,angular,internet-explorer-9,angular2-routing,Angular,Internet Explorer 9,Angular2 Routing,我有这个路由器: ... import { Router, Routes, RouterModule } from '@angular/router'; ... const routes:Routes = [ { path:'', redirectTo:'home', pathMatch:'full'}, { path:'home', component: HomeComponent}, ... ] 我使用 router.navigateByUrl('/home');

我有这个路由器:

...
import { Router, Routes, RouterModule } from '@angular/router';
...

const routes:Routes = [
    { path:'', redirectTo:'home', pathMatch:'full'},
    { path:'home', component: HomeComponent},
    ...
]
我使用

router.navigateByUrl('/home');
它在除IE9之外的所有浏览器中都运行良好

它向当前url添加了一个#,因此如果我导航到
localhost
,它会使
home组件
正常,但url是
localhost/#/home
如果我手动添加
localhost/home
,它将转到
localhost/home/#/home
,并失败


在GitHub问题上找不到任何东西(一些类似的问题,但不相同),我自己也找不到问题。有什么线索吗?

Internet Explorer 9不支持HTML5导航。Angular2默认为IE9上的哈希导航

解决方法是什么?每个人的哈希导航?IE9的不同导航?不支持IE9将是我的默认答案。但是,嘿,我不知道你的情况:)我不知道有什么解决办法,但有一种可能是你在你的Web服务器上处理它。检查是否为IE9,然后在url之前添加哈希。但也许有更好的办法。您是否将基本href设置为
/
?不幸的是,IE9是必需的。base ref已正确设置为/然后我建议我以前的解决方法。哦。。。发脾气,说他们在阻碍进步。这不会是您在IE9中使用angular时遇到的最后一件事,pushstate导航是angular 2+的默认功能吗?我没有在代码中直接使用pushstate函数,但我遇到了同样的问题。