需求:从A页面跳转到B,点击A页面得编辑时携带每条得数据到B页面进行展示。
=========》
A页面
wxml
<view class="content"> <view class="listli" wx:for="{{ addressList }}" wx:key="index" > <view class="left"><view class="round">孙</view></view> <view class="center"> <view class="center_top"> <view class="center_top_left">{{ item.name }}</view> <view class="center_top_right">{{ item.phone }}</view> </view> <view class="center_bottom"> <view wx:if="{{ item.defaultAdd }}" class="center_bottom_left">默认</view> <view class="center_bottom_right">{{ item.address }}</view> </view> </view> <view class="right" bindtap="toedit" data-name="{{ item.name }}" data-phone="{{ item.phone }}" data-address="{{ item.address }}" data-defaultAdd="{{ item.defaultAdd }}"> 编辑 </view> </view> </view>
js
Page({ data: { addressList:[ { name:'孙小荣', phone:'12345678963', address:'天津市', defaultAdd:true },{ name:'孙小荣', phone:'12345678963', address:'', defaultAdd:true },{ name:'孙小荣', phone:'12345678963', address:'天津市', defaultAdd:true },{ name:'孙小荣', phone:'12345678963', address:'天津市', defaultAdd:false } ] }, toedit:function(e){ console.log('1111',e.currentTarget.dataset) wx.navigateTo({ url:"/pages/editAddress/editAddress?name="+e.currentTarget.dataset.name +"&phone="+e.currentTarget.dataset.phone +"&address="+e.currentTarget.dataset.address+"&defaultAdd="+e.currentTarget.dataset.defaultAdd }) }, })
B页面
js
onLoad: function (options) {
console.log('name',options.name)
console.log('address',options.address)
},