方法如下:
1:params
this.$router.push({name: 'test', params: {html: this.html}})
this.$router.push({path: '/details', query: {data: data}})
**注意** 当使用path的时候,参数需要使用query来传,否则在目标页面无法接收到参数
其中name/path的值就是要跳转的目标路由,params的值是参数
在目标路由页面获取参数:
let params = this.$route.params.html
2:query
this.$router.push({name: 'test', query: {html: this.html}})
其中name的值就是要跳转的目标路由,query的值是参数
在目标路由页面获取参数:
let query = this.$route.query.html
本文详细介绍了在Vue中如何使用params和query进行路由传参的方法。通过实例展示了使用path和name的不同方式,并解释了在目标页面如何正确接收这些参数。

1085

被折叠的 条评论
为什么被折叠?



