10.商品列表跳转详情携带商品id

2021-08-06  本文已影响0人  陈情令

代码:

   wx.cloud.database().collection("goods").get().then(res => {

      console.log(res.data)

     this.setData({dataList:res.data})

    }).catch(err => {

      console.log(err)

    })

代码:

<view wx:for="{{dataList}}" wx:key="index" bindtap="jumpAnother" data-id="{{item._id}}">

 <view>商品名称:{{item.name}}</view>

 <view>商品价格:{{item.price}}</view>

</view>

代码:

jumpAnother(e){

     console.log("hhha",e.currentTarget.dataset.id)

     wx.navigateTo({

       url: '/pages/demo/demo?id='+e.currentTarget.dataset.id,

     })

  },

代码:

data: {

    goods:{}

  },

  /**

   * 生命周期函数--监听页面加载

   */

  onLoad: function (options) {

    console.log(options.id,"options")

    wx.cloud.database().collection("goods").doc(options.id).get().then(res => {

      // console.log(res.data)

      this.setData({goods:res.data})

    }).catch(err => {

      console.log(err);

    })

  },

上一篇 下一篇

猜你喜欢

热点阅读