我正在开发一个测试应用程序来学习在线课程。
现在我想使用路由参数,所以我的代码是这样的:
在 app.routing.module.ts 中:
const appRoutes: Routes = [
{ path: '', component: LandingComponent, pathMatch: 'full' },
{ path: 'home', component: HomeComponent},
{ path: 'projects', component: ProjectsComponent},
{ path: 'contacts', component: ContactsComponent},
{ path: 'contacts/:id', component: ContactDetailComponent},
{ path: 'prezzi', component: PrezziComponent}
]
问题来了:
如果我使用路径:“contactsId”,则加载 ContactDetailComponent
如果我使用路径:'contacts/id' 或 'contacts/:id' 并尝试联系,例如,contacts/Pippo,控制台会抛出此错误:
pippo:1 Refused to execute script from 'http://localhost:4200/contacts/styles.js' because its MIME type ('text/html') is not executable, and strict MIME type checking is enabled.
为什么?