当你不仅仅想从这个页面跳转到另外一个页面,而是想要带着参数跳转的话我们应该怎么做呢?
不可以使用router-link这种方法了,我们需要使用vue-router进行传参数
统共来说有两种方法
1.使用params方法传入参数
在script当中写入
this.$router.push({
name: ‘xxx你想要跳转的那个页面’
params:{
id:id//目标页面需要接受的参数
}
})
当目标页面想要接受参数的时候,她需要写上this.$router.params.id
2.使用query反式,其实书写方式和params的方式类似不过从name变成了path
this.$router.push({
path:’/你要去的路径’,
query:{
id:id
}
})
接受参数this.$router.query.id
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。