vue-路由传参
作者:互联网
1.声明式导航(router-link)
<router-link to="/login">登录</router-link>
2.编程式导航($router.push|replace)
params:属于路径一部分,需要占位
{
path:'/search/:keyword?',
component:Search,
name:"search",
meta:{show:true},
props:{a:1,b:2}
},
query:不属于路径一部分,类似于localhost:8080/login?username="hutong"
(1)第一种、字符串形式
this.$router.push('/login/'+this.username+'?time=' + this.time)
(2)第二种、模板字符串
this.$router.push(`/login/${this.username}?time=${this.time}`)
(3)对象式写法
this.$router.push({name:'login',query:{username:this.username},
parmas:{time:this.time}})
标签:传参,username,vue,query,time,push,router,login,路由 来源: https://www.cnblogs.com/hutongtree/p/16664537.html