params:/router1/:id ==》 /router1/123 这里的id叫做params
query:/router1?id=123 ==》 /router1?id=456 这里的id叫做query
1.params
跳转: this.$router.push({ name: 'childPage', params: { id: id } })
要对应路由配置如下:{
path: '/childPage',
name: 'childPage',
component: childPage
}
获取参数:this.$route.params.id
2.query
跳转:this.$router.push({ path: '/childPage', query: { id: id } })
需要对应路由配置如下: {
path: '/childPage',
name: 'childPage',
component: childPage
}
获取参数:this.$route.query.id