跳转前页面js文件

var encodeUrl = encodeURIComponent(param.url)

wx.navigateTo({ url: "../articleDetail/articleDetail?title=" + title + "&mid=" + this.data.mid + "&id=" + id + "&url=" +encodeUrl });

跳转后页面js文件...onLoad:function(options){     this.setData({         title:options.title,         id:options.id,         url: decodeURIComponent(options.url),      }),.....

说明:1、小程序页面跳转传参其中一种方法是:使用?后面加需要传递的参数,如上文中的encodeUrl 参数。

2、如果navigateTo传递的参数本身携带?,可以使用encodeURIComponent和decodeURIComponent编解码,否则会被截断,导致?后面的数据无法传递后跳转页面。

3、对于多行字符串,可以使用反引号``拼接,避免使用一大堆 和加号。

TAG标签: 微信小程序navigate

http://www.xiaochengxub.com/read-103601.html