navigateTo页面跳转传参
使用标签的方式跳转
变量需要{{}}
A页面
<navigator wx:for="{{sendList}}" wx:key="index" url="../cruiseDetail/cruiseDetail?problemId={{item.problemId}}" >
B页面
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
let problemId = options.problemId
this.setData({
problemId:problemId
})
},
使用js方式跳转
A页面跳转链接添加参数,B页面onLoad 接收
A页面
wxml
<view bindtap="goCruiseLog">
<view>
<text class="label">处理记录:</text>
</view>
</view>
js
// 数组、对象都需要stringify
goCruiseLog:function(){
let listData = JSON.stringify(that.data.listData)
let taskArray = JSON.stringify(that.data.taskArray)
wx.navigateTo({
url: '../workRecord/updateBatch?listData=' + listData + '&taskArray=' + taskArray
})
}
B页面
js
onLoad: function (options) {
var that = this
var listData = JSON.parse(options.listData)
var taskArray = JSON.parse(options.taskArray)
}