其他分享
首页 > 其他分享> > vue组件之间通过query传递参数

vue组件之间通过query传递参数

作者:互联网

需求:

从 任务列表进入 任务详情 ,向详情页传递当前 mission_id

路由关系:

    //查看任务列表
    {
        path: '/worklist',
        name: 'worklist',
        component: worklist,
    },
    //任务详情
    {
        path: '/workdetails',
        name: 'workdetails',
        meta: {
            requireAuth: true //需要先登录
        },
        component: workdetails
    },

worklist.vue传递

<router-link :to="{
      path: '/workdetails',
      query: {
          mission_id: index.mission_id //当前missionID
       }
    }"
 class="aaalistlink">
  <el-button icon="el-icon-search" circle type="danger" class="check"></el-button>
</router-link> 

workdetails.vue 中接收参数

var data = {
    mission_id :  this.$route.query.mission_id, //传递的missionID
    user_id :  this.$store.state.user_id
}

 

标签:vue,workdetails,mission,传递,组件,query,worklist,id
来源: https://www.cnblogs.com/CarrotHu/p/10500056.html