第一步:挂载router方法
使用$router跳转传参
toalbumdes(index) {
this.$router.push({
name: "Myalbumdes", //根据注册的组件名称跳转跳转
query: { photoalbumid: index}, //query传参
});
},
this.$router.push({ path: "/home", //根据注册的组件路由跳转跳转 param: {code:"123"} //param 传参(不可见) })
使用$route获取参数(注意是$route,不是$router)
this.$route.query.code
this.$route.param.code //123
<router-link :to="{name:'detail',query:{id:1}}"> xxx </router-link> //router-link传参,同样是this.$route.query.id获取参数