跳转时传入数组参数:
父.wxml
页面
<view class="cu-form-group bg-grey light shadow-blur" bindtap="click" data-item="{{item1.childrenList}}">
<view class="title text-bold"><text class="cuIcon-title text-orange "></text>{{item1.projectName}}</view>
</view>
我们在父.js
文件中可以使用navigateTo
中url
参数携带参数进行跳转,将数组通过JSON.stringify
转成字符串
click(e) {
var model = JSON.stringify(e.currentTarget.dataset.item);
wx.navigateTo({
url: '/pages/recruit/data-report-item/index?model=' + model,
})
},
子.wxml
页面
<view class="table">
<block wx:for="{{childrenList}}" wx:for-item="item1" wx:for-index="index1" wx:key="index1">
<view class="cu-form-group bg-grey light shadow-blur" bindtap="more_click" data-item="{{item1.childrenList}}">
<view class="title text-bold"><text class="cuIcon-title text-orange "></text>{{item1.projectName}}</view>
</view>
</block>
</view>
然后到子.js
文件这边通过 JSON.parse
转换成数组
Page({
data: {
childrenList: [],
},
onLoad(e) {
var childrenList = JSON.parse(e.model)
this.setData({
childrenList: childrenList
})
},
});