我有这条路线/test/a-vs-b
我试图抓住这条路线只有在其中找到-vs-
。
我尝试了一些正则表达式变体,但似乎没有任何效果
routes.push({
name: 'test',
path: '/test/:page((.*)-vs-(.*))',
component: resolve(__dirname, 'test/b.vue'),
});
有任何想法吗?
VueRouter使用path-to-regexp
库,apparently doesn't handle defining capturing groups with parenthesis就像你想要做的那样。
我通过简单地删除围绕.*
s的括号来实现它。
routes.push({
name: 'test',
path: '/test/:page(.*-vs-.*)',
component: resolve(__dirname, 'test/b.vue'),
});