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
}

 

转载于:https://www.cnblogs.com/CarrotHu/p/10500056.html

你可能感兴趣的:(vue组件之间通过query传递参数)