注意取参数都是router,
router是整个VueRouter
方案一
this.$router.push({
path: '/user/123',
})
//对应配置
{
path: '/user/:id',
name: 'User',
component: User
}
//取参数
this.$route.params.id 方案二
利用路由的name属性
this.$router.push({
name: 'User',
params: {
id: id
}
})
//这里可以添加:/id也可以不添加,添加数据会在url后面显示,不添加数据就不会显示
{
path: '/describe',
name: 'Describe',
component: Describe
}
//取参数
this.$route.params.id 方案三
this.$router.push({
path: '/user',
query: {
id: id
}
})
//配置
{
path: '/describe',
name: 'Describe',
component: Describe
}
//取参数
this.$route.query.id 
京公网安备 11010502036488号