我有一个这样的路由:

routes: [
    {
      path: '/survey/:surveyHash',
      name: 'survey',
      component: Survey,
      props: true,
    },

在组件中,我试图获得surveyHash个props .问题是,如果surveyHash个斜线中有/个斜线,我就做不到.

vue路由中有解决方案吗?

推荐答案

可以在路由定义中使用custom matching pattern

routes: [
    {
      path: '/survey/:surveyHash(.*)',
      name: 'survey',
      component: Survey,
      props: true,
    },

有了这个,你将得到URL的其余部分,包括surveyHash中的斜杠

Vue.js相关问答推荐

V-img不显示文件夹中的图像

有没有办法在 Quasar 中为明暗模式创建我自己的 colored颜色 ?

v-on 的 .native 修饰符仅在组件上有效,但在 标签上使用

Vue 3 / Vuetify 3:如何为按钮设置全局默认 colored颜色

将媒体源/流绑定到视频元素 - Vue 3 组合 API

如果在 VueJS/VuetifyJS 中切换switch,则调用函数

VueJS:在组件之间使用全局对象的最佳实践?

Vuex 和 Event Bus 有什么区别?

如何渲染数组以 Select 选项 vue.js

Vue.js 中的 mount挂载是什么意思?

Proxy代理在 Vue 3 的控制台中是什么意思?

Vuejs 3 从子组件向父组件发出事件

错误:Node Sass 尚不支持您当前的环境:Linux 64-bit with Unsupported runtime (88)

使用props向组件添加类名

如果我刷新我的网页,Vuex store是空的

在 vue.js 组件中react this.props.children

使用 Vue.js 获取所有选中复选框的列表

在 Chrome DevTools 中实时更改时 destruct 了 Vue.js 应用程序(Webpack 模板)的页面样式

在 Vuejs 中放置 firebase.auth().onAuthStateChanged() 的位置

Axios 捕获错误请求失败,状态码 404