一聚教程网:一个值得你收藏的教程网站

最新下载

热门教程

vue-router实现组件间的跳转(参数传递)

时间:2017-12-04 编辑:猪哥 来源:一聚教程网

通过VueRouter来实现组件之间的跳转:参数的传递,具体内容如下

login ---用户名--->main

①明确发送方和接收方

②配置接收方的路由地址
{path:'/myTest',component:TestComponent}
-->
{path:'/myTest/:id',component:TestComponent}

③接收方获取传递来的数据
this.$route.params.id

④跳转的时候,发送参数
this.$router.push('/myTest/20')
跳转

代码:



 
 
 传参
 
 
 
 
 

{{msg}}



 
 
 传参练习
 
 
 
 
 

{{msg}}

热门栏目