我正在尝试使用www.domain.com/demolink
导航到演示页面,但我却被丢给了一个错误处理程序。但是,如果我在<a routerLink="/demolink">QT Demo Link</a>
上创建www.domain.com
routerLink,则可以导航到Demo
页面。
我的应用路线如下
export const appRoutes: Routes = [
{path: '', component: LoginComponent},
{path: 'demolink', component:QtDemoLoginComponent},
{path: 'login', component: LoginComponent},
{path: 'app/:errorCode', component: AppComponent},
{path: 'errorHandler', component: ErrorViewComponent},
{path: '**', component: ErrorViewComponent}
];
怎么了?请指教。
答案 0 :(得分:1)
您可能需要将服务器设置为在找不到资源时回退到index.html,以便Angular路由器可以处理请求。 The Angular docs mention this in the section on deployment
在我的Apache virtualhost文件中,我使用FallbackResource
FallbackResource /index.html
,并且有效。您也可以使用重写规则,但这很短而且很容易理解。