Javascript 导航到/主页或新建时无法看到html页面。只显示索引
在这个项目中,我试图学习角度和嵌套组件。由于某些原因,我无法导航到/主页。页面未显示。请帮忙。多谢各位 应用程序路由.module.tsJavascript 导航到/主页或新建时无法看到html页面。只显示索引,javascript,angular,Javascript,Angular,在这个项目中,我试图学习角度和嵌套组件。由于某些原因,我无法导航到/主页。页面未显示。请帮忙。多谢各位 应用程序路由.module.ts const routes: Routes = [ { path: '', pathMatch: 'full', redirectTo: '/home' }, { path: 'home', component: IndexComponent }, { path: 'view/:id', component: ShowComponent }, {
const routes: Routes = [
{ path: '', pathMatch: 'full', redirectTo: '/home' },
{ path: 'home', component: IndexComponent },
{ path: 'view/:id', component: ShowComponent },
{ path: 'new', component: NewComponent },
{ path: 'edit/:id', component: EditComponent },
{ path: '**', component: IndexComponent }
];
只需将代码更新为
[{
path: '',
pathMatch: 'full',
redirectTo: 'home' // you dont need /home
},
{
path: 'home',
component: IndexComponent
}
]