来自 angular docs :
The router link directive always treats the provided input as a delta to the current url.
For instance, if the current url is
/user/(box//aux:team)
. Then the following link<a [routerLink]="['/user/jim']">Jim</a>
will generate the link/user/(jim//aux:team)
.
那么如何创建到/user/jim
的链接呢? ?
我试过了 ['/user/jim', { outlets: { aux: null }}]
但这不起作用。
即使可行,也不是最佳解决方案。我宁愿寻找一种导航到绝对 URL 的方法,也不愿取消可能 导出。
编辑:
关于同一主题,我有一个指向根目录的链接:routerLink="/"
就是这样,它重定向到我的应用程序的根目录,没有像绝对链接这样的任何导出。有趣的是,我并不是特别想要那个特定链接的行为,保留任何导出路线都很好......
最佳答案
截至 2018 年 8 月,Angular docs说:
- If the first segment begins with /, the router will look up the route from the root of the app.
- If the first segment begins with ./, or doesn't begin with a slash, the router will instead look in the children of the current activated route.
- And if the first segment begins with ../, the router will go up one level.
关于angular - routerLink 绝对 url,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39848860/