Angular6+ 自定义模块以及配置路由实现模块懒加载

一、Angular 创建一个默认带路由的项目

ng new angualrdemo --skip-install

二 、创建带路由模块:

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

在这里插入图片描述
各模块中已经自动引入对应模块的组件
在这里插入图片描述
四、手动引入匹配对应模块的路由
在这里插入图片描述
五、配置懒加载
在这里插入图片描述
六、定义路由出口
在这里插入图片描述
运行效果如图 :
在这里插入图片描述
七、在子模块中添加子路由
在上面的基础上添加配置
子模块路由配置
在这里插入图片描述
添加对应跳转按钮
在这里插入图片描述
效果展示
在这里插入图片描述
路由配置完成!

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值