发表于: 2019-10-14 19:41:15
1 899
今天完成的事情
父子路由
1. 创建组件引入组件
2. 配置路由
3. 父组件中定义router-outlet
Angular 内置模块
Angular 自定义模块
当我们项目比较小的时候可以不用自定义模块。但是当我们项目非常庞大的时候把所有的组
件都挂载到根模块里面不是特别合适。所以这个时候我们就可以自定义模块来组织我们的项
目。并且通过Angular 自定义模块可以实现路由的懒加载。
ng g module mymodule
Angular 自定义模块以及配置路由实现模块懒加载
创建模块:
ng g module module/user --routing
ng g module module/article --routing
ng g module module/product --routing
创建组件:
ng g component module/user
ng g component module/user/components/profile
ng g component module/user/components/order
ng g component module/article
ng g component module/article/components/articlelist
ng g component module/article/components/info
ng g component module/product
ng g component module/product/components/plist
ng g component module/product/components/pinfo
配置懒加载
今天遇到的问题
问题1:使用子路由的时候,子路由页面无法显示,路由配置并没有错
解 决:在父路由中配置<router-outlet></router-outlet>,如果没有配置则无法正常显示
今天的收获
学习了父子路由,并学会了如何配置父子路由,这里要记得父路由中配置<router-outlet></router-outlet>
学习了angular中的自定义模块以及相关组件,并学会了懒加载
明天的计划
完成js任务6
评论