Javascript 角度4布线-异常:未捕获(承诺中):错误:找不到要加载的主出口';AppComponent';
我是安格拉尔的新手 当我试图探索Angular4中的路由时,我得到了以下错误 异常:未捕获(承诺中):错误:找不到要加载“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>
<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>
customer
更改为customer
从index.html移动到app.component.html<h1> {{title}} </h1>
<a router-link="">Home</a>
<a router-link="customer">customer </a>
customer
更改为customer
我认为路由器出口应该在应用程序根内的主要组件中。路由器链接的使用应该类似于[router link]=“['/link']”,注意,我将数组传递给路由器链接显示应用程序组件代码@Muthukumar补充道,请检查我认为路由器出口应该在应用程序根内的主要组件中,而且路由器链接的使用应该类似于[router link]=“['/link']”,请注意,我将一个数组传递给路由器链接,显示你的应用程序组件代码@Muthukumar补充道,请检查仍然相同的问题检查仍然相同的问题