Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angular/31.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
在Angular8我遇到了一些路由问题_Angular_Angular Ui Router_Angular Routing - Fatal编程技术网

在Angular8我遇到了一些路由问题

在Angular8我遇到了一些路由问题,angular,angular-ui-router,angular-routing,Angular,Angular Ui Router,Angular Routing,我安装了Angular 8,也安装了用于SEO目的的Universal,所有部分都完成了,我的Angular 8应用程序成功运行。然后我创建一个新组件,该组件的名称为student,然后我转到app routing.modules.ts文件并包括: constroutes:routes=[{path:'/student',component:StudentComponent},] 然后我运行我的应用程序并导航到url,出现以下错误: 错误错误:未捕获(承诺中):错误:无法匹配任何路由。URL段:

我安装了Angular 8,也安装了用于SEO目的的Universal,所有部分都完成了,我的Angular 8应用程序成功运行。然后我创建一个新组件,该组件的名称为
student
,然后我转到
app routing.modules.ts
文件并包括:

constroutes:routes=[{path:'/student',component:StudentComponent},]

然后我运行我的应用程序并导航到url,出现以下错误:

错误错误:未捕获(承诺中):错误:无法匹配任何路由。URL段:“学生”错误:无法匹配任何路由。URL段:路由器上的“学生”\u ApplyRedirects.noMatchError(D:\Angular\mydemo\dist\server\main.js:117488:16)


请帮助我,我尝试了很多次来解决它,但问题仍然是一样的。

请参考下面的URL和代码


如果您遇到任何问题,请告诉我。

请在您的
应用程序路由.modules.ts中尝试此操作:

const routes: Routes = [{path:'student', component:StudentComponent},];

你能分享
app routing.module.ts
app.module.ts
的内容吗?你能显示你的app routing.modules.ts吗?删除
student
aap.module.ts之前的斜线:从“@angular/platform browser”导入{BrowserModule};从“@angular/core”导入{NgModule};从“./app routing.module”导入{AppRoutingModule};从“./app.component”导入{AppComponent};从“./student/student.component”导入{StudentComponent};从'@angular/router'导入{Routes};constroutes:routes=[{path:'students',component:StudentComponent}]@NgModule({declarations:[AppComponent,StudentComponent],app routing.module.ts:-从'@angular/core'导入{NgModule};从'@angular/router'导入{Routes,RouterModule};从'./student/student.component'导入{StudentComponent};@NgModule({imports:[RouterModule.forRoot(routes)],exports:[RouterModule]})export class AppRoutingModule{}很抱歉,没有产生相同的错误。我更改了app-routing.modules.ts和app.module.ts文件,但一旦我转到url()@user12682461,错误是相同的。你能发布你的app.module.ts和app-routing.modules.ts文件吗{NgModule}来自“@angular/core”;导入{Routes,RouterModule}来自“@angular/router”;导入{StudentComponent}来自“/student/student.component”;常量路由:Routes=[{path:'student',component:StudentComponent},];@NgModule({imports:[RouterModule.forRoot(Routes)],exports:[RouterModule]})导出类AppRoutingModule{}从“@angular/platform browser”导入{BrowserModule};从“@angular/core”导入{NgModule};从“/app routing.module”导入{AppComponent};从“/app.component”导入{StudentComponent};从“@angular/router”导入{Routes};const Routes:Routes=[{path:'students',component:StudentComponent}];@NgModule({声明:[AppComponent,StudentComponent请从app.module.ts中删除常量路由:路由=[{path:'students',component:StudentComponent}];并在app.module.ts中添加导入:[AppRoutingModule]