Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/86.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 角度4布线-异常:未捕获(承诺中):错误:找不到要加载的主出口';AppComponent';_Javascript_Jquery_Angular_Angular4 Router - Fatal编程技术网

Javascript 角度4布线-异常:未捕获(承诺中):错误:找不到要加载的主出口';AppComponent';

Javascript 角度4布线-异常:未捕获(承诺中):错误:找不到要加载的主出口';AppComponent';,javascript,jquery,angular,angular4-router,Javascript,Jquery,Angular,Angular4 Router,我是安格拉尔的新手 当我试图探索Angular4中的路由时,我得到了以下错误 异常:未捕获(承诺中):错误:找不到要加载“AppComponent”的主出口 我检查了要修复的链接的数量,但还没有有用的链接 这就是应用程序的外观 index.html <body> <app-root>Loading...</app-root> <router-outlet> </router-outlet> </body>

我是安格拉尔的新手

当我试图探索Angular4中的路由时,我得到了以下错误

异常:未捕获(承诺中):错误:找不到要加载“AppComponent”的主出口

我检查了要修复的链接的数量,但还没有有用的链接

这就是应用程序的外观

index.html

<body>
  <app-root>Loading...</app-root>
  <router-outlet> </router-outlet>
</body>
app.routes.ts

import {RouterModule, Routes } from '@angular/router';
import {AppComponent} from './app.component';
import {CustomerComponent} from './component/customer/customer.component';

export const appRoutes: Routes = [
 { path: '', component: AppComponent },
 { path: 'customer',      component: CustomerComponent },
 {
 path: 'heroes',
 component: AppComponent,
 data: { title: 'Heroes List' }
},
{ path: '',
redirectTo: '/heroes',
pathMatch: 'full'
},
{ path: '**', component: AppComponent }];
app.component.html

<h1> {{title}} </h1>
<a router-link="">Home</a>
<a router-link="customer">customer </a>
}


这里缺少什么配置来执行路由操作???

请正确使用routerlink配置,如下所示
customer
将生成链接/customer/

请正确使用routerlink配置,如下所示<代码>客户将生成链接/客户/

  • 从index.html移动到app.component.html

  • <h1> {{title}} </h1>
    <a router-link="">Home</a>
    <a router-link="customer">customer </a>
    
  • 将app.component.html中的所有链接从
    customer
    更改为
    customer

  • 从index.html移动到app.component.html

  • <h1> {{title}} </h1>
    <a router-link="">Home</a>
    <a router-link="customer">customer </a>
    
  • 将app.component.html中的所有链接从
    customer
    更改为
    customer


  • 我认为路由器出口应该在应用程序根内的主要组件中。路由器链接的使用应该类似于[router link]=“['/link']”,注意,我将数组传递给路由器链接显示应用程序组件代码@Muthukumar补充道,请检查我认为路由器出口应该在应用程序根内的主要组件中,而且路由器链接的使用应该类似于[router link]=“['/link']”,请注意,我将一个数组传递给路由器链接,显示你的应用程序组件代码@Muthukumar补充道,请检查仍然相同的问题检查仍然相同的问题