小程序点击跳转页面并传入一个对象及接受

传参data-item="{{item}}"

	<view wx:for="{{ list }}" wx:key="{{ index }}" catchtap="onclick" data-item="{{item}}">
			<image src="{{ item.images.small }}"></image>
			<text>{{ item.title }}</text>
	</view>

点击事件

 onclick(e){
    let item =e.currentTarget.dataset
    // console.log(item);
    var data = JSON.stringify(item);
    wx.navigateTo({url: '/pages/logs/logs?id='+data,})//跳转页面并传参
  }

另一个页面接受对象

onLoad: function (e) {
    var item = JSON.parse(e.id)
    this.setData({
      list:item
    })
}

猜你喜欢

转载自blog.csdn.net/ZiChen_Jiang/article/details/107825478
今日推荐