小程序中页面之间的id传参【重点】

此博主喜欢直接贴代码

Wxml
<view class='list'>
  <block wx:for='{{apidata}}' wx:key='list' wx:for-item="item" >
  <view class="list_item" bindtap="toNextView" id='{{item.id}}'>
      <view class='info'>
      {{item.id}}
        <view class='title'>{{item.name}}</view>
        <view class='price'>¥{{item.price}}</view>
        <view class='goodstext'>{{item.goodstext}}</view>
      </view>
  </view>
  </block>
</view>
Js
  toNextView: function (e) {
  var goodsid = e.currentTarget.id
    console.log(goodsid)
    wx.navigateTo({
      url: '../goods/goods?id='+goodsid,
      // ?id=1
    })
  },

简洁明了 Giao~

为您推荐

评论已关闭