Open ChenPt opened 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的时候再去匹配动态路由。
/user/xxx
/user/:id
/user/apply
Vue-Router 设置动态路由匹配,会根据路由所定义的顺序来匹配。 假如路由配置如下
遇到路由为
/user/xxx
格式的,永远只会匹配到/user/:id
,不会匹配到/user/apply
,即使路由是/user/apply
,将后者写在前者前面,就会在匹配不到apply的时候再去匹配动态路由。