Angular 4 没有斜杠的路由
Angular 4 routing without slashes
我有一个特别的建议,那就是我们不能在我们的路线中使用斜线。
angular 路由器是否提供不使用斜杠的选项?
我们想使用路由器来提供查询参数。
示例:
url 应该是这样的:http://localhost:4200?item=2&filter=value&site=1
this.router.navigate([], { queryParams: { site: page}});
上面的代码将提供这样的 URL:http://localhost:4200/?site=1
我试图将 index.html 中的基本 href 设置为空字符串,但这不起作用。
<base href="">
有人可以帮我吗?
Angular 提供了两种我们可以用来实现客户端路由的策略,一种叫做
- HashLocationStrategy
- 路径位置策略
Angular 中的默认值是 PathLocationStrategy。
无论哪种方式,您的路线中都会有斜杠。
我有一个特别的建议,那就是我们不能在我们的路线中使用斜线。 angular 路由器是否提供不使用斜杠的选项? 我们想使用路由器来提供查询参数。
示例:
url 应该是这样的:http://localhost:4200?item=2&filter=value&site=1
this.router.navigate([], { queryParams: { site: page}});
上面的代码将提供这样的 URL:http://localhost:4200/?site=1
我试图将 index.html 中的基本 href 设置为空字符串,但这不起作用。
<base href="">
有人可以帮我吗?
Angular 提供了两种我们可以用来实现客户端路由的策略,一种叫做
- HashLocationStrategy
- 路径位置策略
Angular 中的默认值是 PathLocationStrategy。
无论哪种方式,您的路线中都会有斜杠。