<router-link to="/detail" tag="button">
跳转到detail
</router-link>
传变量
<router-link :to="'/detail/'+item.id" tag="button"> //to前面要加冒号
跳转到detail
</router-link>
二、配置路由
{
path: '/detail/:id',
name: 'detail',
component: () => import('../views/Detail.vue')
}
在详情页使用
1-1、接收id
computed:{
id(){
return this.$route.params.id
}
}
1-2发送请求
mounted(){
this.axios.get(`/v2/movie/subject/${this.id}`).then(res=>{
console.log(res)
})
}