ChenPt / dailyNote

dailyNode for myself
https://github.com/ChenPt/dailyNote/issues
0 stars 0 forks source link

2018/08/21 记录今天遇到的路由BUG #29

Open ChenPt opened 6 years ago

ChenPt commented 6 years ago

Vue-Router 设置动态路由匹配,会根据路由所定义的顺序来匹配。 假如路由配置如下

const router = new VueRouter({
  routes: [
    {
      path: '/user/:id'
    },
    {
      path: '/user/apply'
    }
  ]
})

遇到路由为/user/xxx格式的,永远只会匹配到/user/:id,不会匹配到/user/apply,即使路由是/user/apply,将后者写在前者前面,就会在匹配不到apply的时候再去匹配动态路由。