4.归纳.md 845 B

路由

  1. vue-router
  2. vue2.0 => 3
  3. vue3.0 => 4
  4. 安装:npm install vue-router@3 --save
  5. vuex: npm install vuex --save

  6. router.js

    • 引入页面路径
    • 将路径挂载到路由上

      {
      path:"/路径",
      component: 引入页面路径的名称
      }
      
  7. App.vue

    跳转标签:
    router-link
    属性:
        to:跳转路径地址
        active-class="active" 添加选中样式
    占位标签:
    router-view 
    
  8. 多级路由

  9. router.js

    1. 引入路径
    2. 在children属性中添加路由
    3. path路径不要加:/
  • router-link
    • to的路径完整的路径
  1. 路由的重定向

    {
    path:'/',
    redirect: '/list'
    }
    
  2. 路由命名

  3. router.js

    • name:"xxx"

      <router-link active-class="active" :to="{name:'xxx'}"></router-link>