微信小程序实现页面跳转有两种方式,一种是在wxml中实现跳转,一种是在js中实现跳转。
在wxml中跳转并传参的实现方式为:
navigator class='li' url='../record/record?type="CHECK"&record={{record)}}'在js中跳转并传参的实现方式为(以navigate为例):
wx.navigateTo({ url: '../record/record?type=' + recordType + '&record=' + JSON.stringify(record), })tips:JSON.stringify()方法用于将对象(数组)转换为字符串,JSON.parse方法用于将字符串转换为对象(数组)
获取参数的方法:
onLoad: function (options) { this.setData({ recordList: JSON.parse(options.record), recordType: options.type }); // 设置title var title; if (this.data.recordType == 'title1'){ title = '标题1'; } else if (this.data.recordType == 'title2'){ title = '标题2'; } else if (this.data.recordType == 'title3'){ title = '标题3'; }else{ title = '标题4'; } wx.setNavigationBarTitle({ title: title }) },tips:
wx.setNavigationBarTitle为修改title的方法













