1、在URL中显示传递的参数query
2、不在URL中显示传递的参数params
用params传参必须要加name属性,不然获取不到参数,name是在router index.js中注册的组件名
页面A
enterNews(id,type){
this.$router.push({
path: "/view",
name:"textview",
query: {id: id },
params: { type: type }
});
}
页面B
created(){
//接受传递过来的文章id
this.newsId = this.$route.query.id;
//接受传递过来的文章类型
this.newsType = this.$route.params.type;
},