我有一个作业模块,其中包含我的应用程序的各种组件。我想对所述模块进行延迟加载,但是,当我尝试通过完整路径访问时它不起作用,也就是说,如果我通过路径访问http://localhost:4200/job/artist
它不起作用但如果我通过它访问http://localhost:4200/#/artist
它是否有效。知道为什么会这样吗?
延迟加载模块的路由模块
import { NgModule } from '@angular/core';
import { RouterModule, Routes } from '@angular/router';
import { Artist } from './components/artist/artist.component';
const routes: Routes = [{
path: 'job',
loadChildren: () => import('../jobs/jobs.module').then(m => m.JobsModule)
}];
@NgModule({
imports: [
RouterModule.forRoot(routes, {
useHash: true,
}),
BrowserModule],
exports: [RouterModule]
})
export class LazyRoutingModule { }
作业路由.module.ts
import { NgModule } from '@angular/core';
import { RouterModule, Routes } from '@angular/router';
import { Artist } from './components/artist/artist.component';
const routes: Routes = [{
path: 'artist',component: ArtistComponent,
}];
@NgModule({
imports: [RouterModule.forChild(routes)],
exports: [RouterModule]
})
export class JobsRoutingModule { }