小程序怎样获得当前页面的id
小程序获得当前页面id的案例:
.wxml文件代码:
<blockwx:for-items="{{newGoods}}"wx:key="id">
<viewcatchtap="catchTapCategory"data-goodsid="{{item.id}}">
<view>
<imagesrc="{{item.imgUrl}}"/>
</view>
<viewclass="product-name">
{{item.name}}
</view>
</view>
</block>
.js文件代码:
catchTapCategory:function(e){varthat=this;
vargoodsId=e.currentTarget.dataset.goodsid;
console.log('goodsId:'+goodsId);
wx.navigateTo({url:'../detail/detail?goodsId='+goodsId})
},
本文来源:https://www.yuntue.com/post/80145.html | 云服务器网,转载请注明出处!