1. <router-link to="/detail" tag="button">
  2. 跳转到detail
  3. </router-link>

传变量

  1. <router-link :to="'/detail/'+item.id" tag="button"> //to前面要加冒号
  2. 跳转到detail
  3. </router-link>

二、配置路由

  1. {
  2. path: '/detail/:id',
  3. name: 'detail',
  4. component: () => import('../views/Detail.vue')
  5. }

在详情页使用

1-1、接收id

  1. computed:{
  2. id(){
  3. return this.$route.params.id
  4. }
  5. }

1-2发送请求

  1. mounted(){
  2. this.axios.get(`/v2/movie/subject/${this.id}`).then(res=>{
  3. console.log(res)
  4. })
  5. }