一、直接在路由中写参数(刷新页面参数不会丢失)
{path: '/detail/:id',name: 'Detail',component: Detail
}
var id = 1;
this.$router.push({path: `/detail/${id}`,
})
this.$route.params.id
二、通过query属性传值(刷新页面参数不会丢失)
{path: '/detail',name: 'Detail',component: Detail
}
this.$router.push({path: '/detail',query: {name: '张三',id: 1,}
})
this.$route.query
三、通过params属性传值(刷新页面参数会丢失)
{path: '/detail',name: 'Detail',component: Detail
}
this.$router.push({name: 'Detail',params: {name: '张三',id: 1,}
})
this.$route.params