要解决Angular 8路由子项显示错误,你可以尝试以下几个解决方法:
const routes: Routes = [
{ path: 'parent', component: ParentComponent,
children: [
{ path: 'child', component: ChildComponent }
]
}
];
检查你的子组件是否有与路由路径匹配的样式。如果你的子组件的样式设置了display:none或其他隐藏元素的样式,那么它将不会显示。
如果你使用了懒加载模块,确保在父模块中正确导入并加载子模块。例如,如果你的子模块是使用懒加载加载的,你的父模块应该类似于这样:
import { ChildModule } from './child/child.module';
@NgModule({
imports: [
// other imports
ChildModule
],
declarations: [
// declarations
]
})
export class ParentModule { }
请注意,这只是一些可能的解决方法之一,具体取决于你的代码和问题的具体细节。如果问题仍然存在,请提供更多的代码示例和错误信息,以便我们能够更好地帮助你解决问题。