我在我的应用程序中做了一个简单的路由,并且在localhost上一切正常,但是当我在托管上载dist文件夹时,ng build
我无法访问特定链接,当我在浏览器上输入它们时,为www.mydomain.com/login
。我在app.module声明中导入routableComponents
。
const routes: Routes = [
{
path: '',
pathMatch: 'full',
redirectTo: 'main/posts'
},
{
path: 'main',
component: MainComponent,
children: [
{
path: 'posts',
component: PostListComponent,
},
{
path:'posts/watching',
component: WatchingComponent
},
{
path: 'posts/reading',
component: ReadingComponent
},
{
path: 'posts/brickets',
component: BricketsComponent
},
},
{
path: 'login',
component: LoginComponent
}
];
@NgModule({
imports: [RouterModule.forRoot(routes)],
exports: [RouterModule]
})
export class AppRoutingModule {
}
export const routableComponents = [
PostListComponent,
LoginComponent,
WatchingComponent,
ReadingComponent,
BricketsComponent,
MainComponent
];