代码改变世界

微信小程序路由跳转及参数接收

2019-08-14 19:09  极光の地  阅读(3269)  评论(0编辑  收藏  举报

* 方式一

传递数据在 url 后面加?携带参数

wx.navigateTo({
   url: '../login/login?username=abc',
   success: function(res) {
   },
   fail: function(res) {
   },
   complete: function(res) {
   },
})

* 方式二

<navigator url="./home/home">跳转到新页面</navigator>

* 取出数据

取出传递的数据

this.data.username

其它的如重定向、跳转到tabtar 可以参考微信小程序官方 api

https://developers.weixin.qq.com/miniprogram/dev/api/route/wx.navigateBack.html