如何从Angular5中的URL中删除哈希?
问题描述:
角路由(在我的app-routing.module.ts中)
Angular Routing(In my app-routing.module.ts)
@NgModule({
exports: [ RouterModule ],
imports: [ RouterModule.forRoot(routes) ],
declarations: []
})
在index.html中,我添加了<base href="/">
In index.html I have added <base href="/">
但是在URL中,我可以看到#
我的应用程序已部署在JBoss AS 7.1.1 Server上
But in the URL I can see the #
My application is deployed on JBoss AS 7.1.1 Server
答
在您的应用模块中执行此操作.在此处中找到有关哈希定位策略的更多信息.
In your app module do this. Find more information in here about hash location strategy.
@NgModule({
imports: [
// other imports
RouterModule.forRoot(routes, { useHash: false })
],
declarations: [
],
providers: [
],
bootstrap: [ AppComponent ]
})
export class AppModule { }