gpt4 book ai didi

angular - 无法读取 Angular 路由中未定义的属性 'split'

转载 作者:行者123 更新时间:2023-12-03 16:18:05 25 4
gpt4 key购买 nike

我在我的 Angular 应用程序中实现了延迟加载。我从 app.routes 文件加载登录和仪表板模块,直到此时一切都可以通过延迟加载正常工作。我在尝试使用 loadChildren 将其他子路由加载到 dashboard.routes 时遇到问题,也就是说,子路由中的子路由。

应用程序模块

import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { AppComponent } from './app.component';

@NgModule({
declarations: [
AppComponent
],
imports: [
BrowserModule,
AppRoutingModule
],
bootstrap: [AppComponent]
})
export class AppModule { }

应用路由.module.ts

import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';


const routes: Routes = [
{
path: 'login',
loadChildren: 'app/modules/login/login.module#LoginModule'
},
{
path: 'dashboard',
loadChildren: 'app/modules/dashboard/dashboard.module#DashboardModule'
},
{ path: '**', redirectTo: 'login', pathMatch: 'full' }
];

@NgModule({
imports: [RouterModule.forRoot(routes)],
exports: [RouterModule]
})
export class AppRoutingModule { }

仪表板.module.ts

import { NgModule } from "@angular/core";
import { MainRoutingModule } from "@app/modules/main/main-routing.module";
import { MainLayoutComponent } from "@app/modules/main/views/main-layout/main-layout.component";
import { BlankComponent } from '../blank/blank.component';

@NgModule({
imports: [DashboardRoutingModule],
declarations: [DashboardComponent]
})
export class DashboardModule { }

dashboard-routing.module.ts

import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { DashboardComponent } from '../blank/blank.component';

const routes: Routes = [
{
path: '',
component: DashboardComponent,
children: [
{
path: 'clients',
loadChildren: './../clients/clients.module#CLientsModule'
},
{
path: 'users',
loadChildren: './../users/users.module#UsersModule'
},
{ path: '', redirectTo: '/users', pathMatch: 'full' }
]
}
];
@NgModule({
imports: [RouterModule.forChild(routes)],
exports: [RouterModule]
})
export class DashboardRoutingModule { }

客户端模块

import { NgModule } from "@angular/core";

import { CommonModule } from '@angular/common';
import { ClientsComponent } from './clients.component';
import { CLientsRoutingModule } from './clients-routing.module';


@NgModule({
imports: [
CommonModule,
CLientsRoutingModule
],
declarations: [ClientsComponent]
})
export class CLientsModule { }

客户端.路由

import { Routes, RouterModule } from '@angular/router';
import { NgModule } from '@angular/core';
import { CLientsComponent } from './clients.component';

const routes: Routes = [
{
path: '',
component: CLientsComponent
}
];
@NgModule({
imports: [RouterModule.forChild(routes)],
exports: [RouterModule]
})
export class ClientsRoutingModule { }

enter image description here

这是一个一般错误。未捕获( promise ):类型错误:无法读取未定义的属性“拆分”类型错误:无法读取未定义的属性“拆分” 默认 UrlMatcher ( http://localhost:4200/vendor.js:83027:28 ) 在比赛中 ( http://localhost:4200/vendor.js:85220:15 ) 在 ApplyRedirects.push../node_modules/@angular/router/fesm5/router.js.ApplyRedirects.matchSegmentAgainstRoute ( http://localhost:4200/vendor.js:85066:18 ) 在……

最佳答案

我在没有指定路由路径的时候也出现了这个错误。

关于angular - 无法读取 Angular 路由中未定义的属性 'split',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57339489/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com