我有一个像这样的路由器:
routes: [
{
path: '/survey/:surveyHash',
name: 'survey',
component: Survey,
props: true,
},
在组件中,我尝试在 Prop 中获取
surveyHash
。麻烦的是,当/
中存在surveyHash
斜杠时,我无法执行此操作。vue-router中有解决方案吗?
最佳答案
您可以在路线定义中使用custom matching pattern
routes: [
{
path: '/survey/:surveyHash(.*)',
name: 'survey',
component: Survey,
props: true,
},
有了这个,您将获得URL的其余部分,包括
surveyHash
中的斜杠。关于javascript - Vue路由器/:param with slashes,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/53890365/