首页 > 其他 > 详细

mpvue路由传参报错Cannot read property 'query' of undefined

时间:2020-02-28 11:22:10      阅读:169      评论:0      收藏:0      [点我收藏+]

  在mpvue编写的小程序项目中,页面跳转间我希望通过编程式导航传递些参数

  • 传参页面代码:  
this.$router.push({path:‘/pages/login/changePassword/main‘,query:{phone:this.phoneNumber,code:this.verificationCode}})
  • 接参页面代码:
created () {
    this.phoneNumber = this.$route.query.phone
    this.verificationCode = this.$route.query.code
}

  

  按照vue的方式来看上面的代码不应该有什么问题,但是在mpvue中就有了如下的报错:

  技术分享图片

 

   

  再说一下解决办法:

  接参页面获取参数的代码不能写在生命周期函数  created  中,而应该写在 mounted 中。就这样,调整一下生命周期函数也就解决了。  

 

mpvue路由传参报错Cannot read property 'query' of undefined

原文:https://www.cnblogs.com/belongs-to-qinghua/p/12375901.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!