router和route

1、router

用来在跳转之前的页面发送参数的对象

//方法一:
//name:路由名称 params:要传递的参数
//这种方法不会在url中暴露参数
this.$router.push({
    
    
	name:"index",
	params:{
    
    
		id:this.id,
	}
});

//方法二:
//path:路由的路径 query:要传递的参数
//这种方法不会在url中暴露参数
this.$router.push({
    
    
	path:"/index",
	query:{
    
    
		id:this.id,
	}
});

2、route

用来在接收数据的页面接收参数

//接收方法一的参数
let id = this.route.params.id;
//接收方法二的参数
let id = this.route.query.id;

猜你喜欢

转载自blog.csdn.net/ABidMan/article/details/129518366
今日推荐