前言:
上次简单介绍了vue-router,并且创建了两个路由,如果还没学过路由基础知识请点这里

子路由:
比如有一个地址,圈出的地方在about目录下,可以是ChildRouter1,也可以是ChildRouter2,那么ChildRouter1、ChildRouter2就叫做about的子路由

 vue子路由children的使用

 

 


创建子路由的步骤:
  1. 在components目录下创建两个文件,分别是ChildRouter1.vue、ChildRouter2.vue,两个文件的内容相似即

    vue子路由children的使用

     

    vue子路由children的使用

     

     

  2. 在老父亲about.vue中添加一行。router-view是为了给子模板提供插入位置。ChildRouter1.vue、ChildRouter2.vue是about的子页面,就像继承一样


     vue子路由children的使用

     

     

  3. 在Router文件夹的index.js中添加路由规则
     
    vue子路由children的使用

     

    效果
     
     
    vue子路由children的使用

     

     

    vue子路由children的使用

     

     

相关文章:

  • 2022-12-23
  • 2022-01-06
  • 2022-02-27
  • 2022-12-23
  • 2022-12-23
  • 2021-08-29
  • 2021-07-09
  • 2022-01-12
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-04-15
  • 2022-12-23
  • 2021-06-09
  • 2021-08-18
  • 2021-03-31
相关资源
相似解决方案