Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/401.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 导航到/主页或新建时无法看到html页面。只显示索引_Javascript_Angular - Fatal编程技术网

Javascript 导航到/主页或新建时无法看到html页面。只显示索引

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

在这个项目中,我试图学习角度和嵌套组件。由于某些原因,我无法导航到/主页。页面未显示。请帮忙。多谢各位

应用程序路由.module.ts

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
  }
]