先谢谢你。
我试图点击菜单栏,在这里我提到了路由路径的href,并在IIS上托管。当我点击UI上的菜单时,它没有发生任何事情,也没有进入相应的组件,它将进入默认的路由路径,但它在本地端口4200工作。我努力尝试了很多天,但无济于事,谁能帮助我得到正确的实现。
这是我的HTML组件,在这里我把href给了路由路径。
新鲜蔬菜
</li>
<li class="menu-item-has-children dropdown">
<a href="Wheat" class="dropdown-toggle" aria-haspopup="true" aria-expanded="false"> <i class="menu-icon fa fa-cogs"></i>Wheat</a>
</li>
**
这是我的路线。
{
path:'Veg',
component:VegetablesComponent,
canActivate :[AuthGuard]
},
这是我的索引
<base href="./">
这是我在IIS中的网页配置
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="Angular Routes" stopProcessing="true">
<match url=".*" />
<conditions logicalGrouping="MatchAll">
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
<add input="{REQUEST_URI}" pattern="^/(api)" negate="true" />
</conditions>
<action type="Rewrite" url="/ePortal/" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
解决方案:
你的锚会一直刷新你的应用,因为angular不会得到通知去拦截它。
使用 <a routerLink="/first-component">
而不是。
更多信息,请看。https:/angular.ioguiderouter)。