1、第一种方式
this.$router.push({
name: 'userPortraitList',
params: {
item: this.recordDetail
}
});
2、第二种方式
this.$router.push({
path:'/userPortraitList',
query: {
msg: '我是参数',
},
});
3、接收数据
mounted() {
console.log(this.$route.query);
console.log(this.$route.params);
}
4、区别
- 以query方式传递数据是通过URL传递的,类似ajax中的get方式,参数在地址栏中可以看到。
- 以params方式传递参数,类似ajax中的post方式,可以传递对象,推荐使用这种方式!
- name和path区别开,一个带 / ,一个不带 /