在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中就有了如下的报错:

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

 

   

  再说一下解决办法:

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

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-10-11
  • 2022-12-23
  • 2021-10-30
  • 2021-12-24
  • 2021-09-17
  • 2021-04-02
猜你喜欢
  • 2021-11-30
  • 2021-09-17
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案