Angular2在网址中没有哈希值 [英] Angular2 without hash in the url
本文介绍了Angular2在网址中没有哈希值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
现在,我的网站的网址如下所示,因为我使用的是这里
http:// localhost:4200 /#/ cadastro
是否有可能删除网址中的散列并且不会收到404错误?
编辑:添加路由器模块
const appRoutes:Routes = [
{path:'',component:HomeComponent},
{path:'cadastro',component:CadastroNoivosComponent},
{path:'**',component: HomeComponent}
];
export const routing = RouterModule.forRoot(appRoutes);
解决方案
如果您使用 PathLocationStrategy ,如这里你可以删除URL中的哈希。
摆脱404错误需要一些服务器端的调整。一个简单快速的方法是,当请求
查看全文