美文网首页
vue-router路由跳转参数的传递和接收

vue-router路由跳转参数的传递和接收

作者: 子涵_520 | 来源:发表于2018-10-09 10:31 被阅读0次

路由跳转的方式(编程式,声明式)

1.编程式

this.$router.push()有四种方式

// 字符串
this.$router.push('路径')

// 对象
this.$router.push({path:"×××××?name"+this.name})

// 命名的路由
this.$router.push({name:"",params:{key:value}})
(name指的是路由配置文件中的name)


image.png

//带参数查询
this.$router.push({path:"",query:{key:value}})

获取参数

路由传递的参数通过this.route.params/this.route.query

相关文章

网友评论

      本文标题:vue-router路由跳转参数的传递和接收

      本文链接:https://www.haomeiwen.com/subject/dbhznftx.html