二级路由,由叫嵌套路由

一、配置

  1. {
  2. path: '/city',
  3. name: 'city',
  4. component: City,
  5. children:[
  6. {
  7. path:'hotCity',
  8. component:()=>import('@/components/HotCity')
  9. },{
  10. path:'newCity',
  11. component:()=>import('@/components/NewCity')
  12. }
  13. ]
  14. }

二、在city.vue组件中配置router-view

  1. <template>
  2. <div>
  3. <router-view></router-view>
  4. <p>city</p>
  5. </div>
  6. </template>