got this error, Error: Cannot match any routes
got this error, Error: Cannot match any routes
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { RouterModule, Routes } from '@angular/router';
import { LmfinComponent } from '../app/lmfin/lmfin.component';
import { MfinComponent } from './mfin/mfin.component';
import { GenFunctionProvider } from './gen-function.module';
import {DetailpembayaranComponent } from './detailpembayaran/detailpembayaran.component';
const appRoutes:Routes = [ //removed export
{ //removed square bracket
path: '',
redirectTo: '/mfin',
pathMatch: 'full'
},{
path: 'list',
component: LmfinComponent
},{
path: 'mfin/:id',
component: MfinComponent
},{
path: 'detailpembayaran',
component: DetailpembayaranComponent
}
];
@NgModule({
imports: [
CommonModule,
RouterModule.forRoot(appRoutes, {useHash:true})
],
declarations: []
})
export class AppRoutingModule { }
我在路由方面还是个新手,当我尝试进行路由时,我遇到了这个错误
ERROR Error: Uncaught (in promise): Error: Cannot match any routes.
有人可以帮我吗?
您的默认重定向路径 /mfin
你没有路径 /mfin
你有 URL /mfin/:id
。这与 /mfin
不匹配
因此需要添加 /mfin
的路线 URL。
试试这个,据我所知,您在 index.html 中缺少一些代码。检查您的 index.html head 部分是否有以下代码。如果没有加进去看看。
<base href="/">
还要确保您的服务器已配置 HTML5 pushState,如
中所述
希望这能解决您的问题。如果您有任何疑问或建议,请告诉我。
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { RouterModule, Routes } from '@angular/router';
import { LmfinComponent } from '../app/lmfin/lmfin.component';
import { MfinComponent } from './mfin/mfin.component';
import { GenFunctionProvider } from './gen-function.module';
import {DetailpembayaranComponent } from './detailpembayaran/detailpembayaran.component';
const appRoutes:Routes = [ //removed export
{ //removed square bracket
path: '',
redirectTo: '/mfin',
pathMatch: 'full'
},{
path: 'list',
component: LmfinComponent
},{
path: 'mfin/:id',
component: MfinComponent
},{
path: 'detailpembayaran',
component: DetailpembayaranComponent
}
];
@NgModule({
imports: [
CommonModule,
RouterModule.forRoot(appRoutes, {useHash:true})
],
declarations: []
})
export class AppRoutingModule { }
我在路由方面还是个新手,当我尝试进行路由时,我遇到了这个错误
ERROR Error: Uncaught (in promise): Error: Cannot match any routes.
有人可以帮我吗?
您的默认重定向路径 /mfin
你没有路径 /mfin
你有 URL /mfin/:id
。这与 /mfin
因此需要添加 /mfin
的路线 URL。
试试这个,据我所知,您在 index.html 中缺少一些代码。检查您的 index.html head 部分是否有以下代码。如果没有加进去看看。
<base href="/">
还要确保您的服务器已配置 HTML5 pushState,如
希望这能解决您的问题。如果您有任何疑问或建议,请告诉我。