Vue路由传参
路由
跳转
标签形式
<router-link :to="{path:'/'}">登录</router-link>
<router-link :to="{name:'Index'}">个人中心</router-link>
编程跳转
this.$router.replace({
// path:"/my",
name:"My"
})
跳转传参
query
<router-link
:to="{ path: '/essay', query: { id: essay.id } }"
>
<h4>{{ essay.title }}</h4>
</router-link>
this.$router.push({
path:"/essay",
query:{
id: essay.id
}
})
- 接收参数
this.$route.query.id
params
this.$router.push({
name:"Essay",
params:{
id: essay.id
}
})
- 接收参数
this.$route.params.id