我想添加一个 url 路径,而不重定向页面。
就像我在 /home/ 页面上一样,我想移动到 /home/item1 而不触发重定向。
我在堆栈上找到了很多示例,但它们都不能在 Angular 7 中工作。
location.go 或 location.replaceState 无法从
constructor(private location: Location) { }
Run Code Online (Sandbox Code Playgroud)
我正在尝试在 Angular 7 中找到一种方法。
这里的其他解决方案: Angular2:无法使用location.go(url)导航到url
使用:
import {Location} from '@angular/common';
constructor(private location: Location){}
location.go('myurl');
Run Code Online (Sandbox Code Playgroud)
对我有用:)
| 归档时间: |
|
| 查看次数: |
6183 次 |
| 最近记录: |