1.直接调用$router.push 实现携带参数的跳转
this.$router.push({
path: `/describe/${id}`
}
需要对应路由配置如下:
{
path: '/describe/:id',
name: 'Describe',
component: Describe
}
this.$route.params.id
2.name params方式
this.$router.push({
name: 'Describe',
params: {
id: id
}
})
{
path: '/describe',
name: 'Describe',
component: Describe
}
this.$route.params.id
3.query传递的参数会显示在url后面?id=?
this.$router.push({
path: '/describe',
query: {
id: id
}
})
{
path: '/describe',
name: 'Describe',
component: Describe
}
this.$route.query.id