从路由器链路中删除本地主机:4200/xxx



我想使用 angular 7 中的路由器链接重定向到另一个链接,但 localhost:4200/dashboard 被附加到我要重定向的链接。

<a  [routerLink]="https://google.com">Google</a>

当我点击谷歌时,它应该重定向到 https://google.com 但是 localhost:4200/dashboard/https://google.com 正在被调用。

routerLink用于Angular的内部路由。如果要导航到外部 URL,只需将hrefa标记一起使用:

<a  href="https://google.com">Google</a>

路由器链路:https://angular.io/api/router/RouterLink

顾名思义,routerLink它适用于应用路由中定义的内部 URL。请使用此 URL 了解如何实现自定义 URL。

https://medium.com/@adrianfaciu/using-the-angular-router-to-navigate-to-external-links-15cc585b7b88

https://stackblitz.com/edit/angular-external-links

最新更新