1、query的方式

<router-link :to="{path:'/test',query: {name: id}}">跳转</router-link>

使用:this.$route.query.id

地址栏: http://localhost:8081/#/test?name=1

 

2、params的方式

<router-link :to="{name:'/test',params: {id: id}}">跳转</router-link>

使用:this.$route.params.id

地址栏: http://localhost:8081/#/test/12345

 

配置路由:

{
  path: '/test/:id',
  component: testingCenter,
  meta: { title: '检测中心' }
}

传参:

<router-link :to="'/test/'+id">跳转</router-link>

使用:this.$route.params.id(这个id给上图路由的配置有关)

地址栏:http://localhost:8081/#/test/1

Logo

前往低代码交流专区

更多推荐