angular路由学习笔记

191 阅读1分钟
  1. 需要在index.html中的<head>添加中添加一个<base>标签,指定根路由,告诉angular如何合成路由
  2. 路由模块不是核心模块需要通过@angular/router包导入
  3. 路由定义中path不能以/开头
  4. 路由的顺序很重要,先匹配者优先
  5. enableTarcing:true 调试使用,将导航生命周期中的时间打印到浏览器控制台
  6. <a>标签中routerlink绑定是一次性绑定
  7. 配置默认路由及通配符路由
  8. pathMatch:full 完全匹配 prefix前缀匹配
  9. 只在根模块 AppRoutingModule 中调用 RouterModule.forRoot()(如果在 AppModule 中注册应用的顶级路由,那就在 AppModule 中调用)。 在其它模块中,你就必须调用RouterModule.forChild方法来注册附属路由。
  10. 路由配置的导入顺序很重要