纯跳转
this.$router.push('/home') // 向地址栏历史添加一条。可以回退
this.$router.replace('/home') // 不添加跳转历史
params参数
this.$router.push({
name: 'home' , // 或者可以写成 path: '/home'
params: { // 这种参数不会带在地址栏上
name: '啦啦',
info: { age: 18, sex: 'man'}
}
})
query参数
this.$router.push({
name: 'home' , // 或者可以写成 path: '/home'
query: { // 这种参数会带在地址栏上
name: '啦啦',
info: '哈哈'
}
})
拼接
this.$router.push({
path: '/home?name=' + this.name
})
获取参数
this.$route.params.name
this.$route.query.name
就酱~