路由模块具有通用的标签标记{ useHash: true }
,没有特定的路径。
{ path: 'documentDelivered', component: DocumentDeliveredComponent },
{ path: 'health', component: MonitoringComponent },
@NgModule({
imports: [RouterModule.forRoot(routes, { useHash: true })],
http://localhost:4200/#/documentDelivered
我只需要删除“健康”路径下的主题标签(#)。
答案 0 :(得分:0)
我执行的步骤很正常
现在它可以在开发环境中正常工作了。
对于产品,我们需要在(.htaccess)文件中添加规则。
修复了将重定向限制到路由器中的同级和子级路径的问题。 基本上,问题出在产品中,而不是在开发中。
<IfModule mod_rewrite.c>
RewriteEngine On
# Redirection of requests to index.html
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} -f [OR]
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^(.*) index.html [NC,L]
</IfModule>
参考:https://julianpoemp.github.io/ngx-htaccess-generator/#/generator
欢呼:)