【vue】vue跳转页面传递参数

前言

自己每次用的时候,都是百度,找到合适的要半天,所以就找一篇好点的搬运过来了。
转载自:https://blog.csdn.net/qi_dabin/article/details/82454588
其实以前在博客园看过一篇写的特详细,可惜找不到了

注意事项

跳转是通过tourer,获取参数通过route!!

第一种:push

跳转

this.$router.push({
    
    
path: `/describe/${
      
      id}`,
})

路由配置

{
    
    
path: '/describe/:id',
name: 'Describe',
component: Describe
}

获取参数

this.$route.params.id

第二种:name

跳转

this.$router.push({
    
    
	name: 'Describe',
	params: {
    
    
		id: id
	}
})

路由

{
    
    
	path: '/describe',
	name: 'Describe',
	component: Describe
}

获取参数

this.$route.params.id

第三种:path

跳转

this.$router.push({
    
    
	path: '/describe',
	query: {
    
    
		id: id
	}
})

路由

{
    
    
	path: '/describe',
	name: 'Describe',
	component: Describe
}

获取参数

this.$route.query.id