小程序 小程序页面 页面id

小程序如何获取当前页面的id

小新
557
2020-12-07 15:58:45
栏目: 云计算

小程序如何获取当前页面的id

小程序获取当前页面id的案例:

.wxml文件代码:

          

<block wx:for-items="{{newGoods}}" wx:key="id">

            <view  catchtap="catchTapCategory" data-goodsid="{{item.id}}">

              <view>

                <image src="{{item.imgUrl}}" /> 

              </view>

              <view class="product-name">

                {{item.name}}           

              </view>

</view>

</block>

.js文件代码:

catchTapCategory: function (e) {

    var that = this;

    var goodsId = e.currentTarget.dataset.goodsid;

    console.log('goodsId:' + goodsId);    

    wx.navigateTo({ url: '../detail/detail?goodsId=' + goodsId })

 },



0
看了该问题的人还看了