Skip to content

一、vue-router

官网参考:

1. 路由模式(hash、H5 history)

2.路由配置(动态路由、懒加载)

  • vue-router history

    vue
      const router = new VueRouter({
        mode: 'history',
        routes: [...]
      })
  • 动态路由

    vue
    const router = new VueRouter({
      routes: [
       // 动态路径参数 以冒号开头。能命中 `/user/10` `/user/20` 等格式的路由 
       { path: '/user/:id', component: User }
      ]
     })
  • 路由懒加载

    vue
      const router = new VueRouter({
      routes: [
       { path: '/', component: () => import('xxxx') }
      ]
     })

Released under the MIT License.