vue query或params传参

时间:2021-03-05 06:41:18

1.query

  传递端:

  this.$router.push({

    path:"/AccountFP",

    query:{

      id:row.id,

      userId:row.userId

    }

  })

  接受端:

  console.log(this.$route.query,id)

  console.log(this.$route.query,userId)

2:params

  1:传递端

  

this.$router.push({
name:'xxx'
params:{
id:id
}
})

  接受:

this.$route.params.id

  注意:params传参,push里面只能是 name:'xxxx',不能是path:'/xxx',因为params只能用name来引入路由,如果这里写成了path,接收参数页面会是undefined!!