Vue中router-link路由跳转以及传参方式
1、query的方式<router-link :to="{path:'/test',query: {name: id}}">跳转</router-link>使用:this.$route.query.id地址栏:http://localhost:8081/#/test?name=12、params的方式<router-link :to="...
·
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给上图路由的配置有关)
更多推荐
已为社区贡献12条内容
所有评论(0)