小程式傳id值
阿新 • • 發佈:2018-11-10
xml檔案
<view class='bgcf bsbb pl30 pr30 pt30 pb30 df fww' >
<block wx:for="{{introduction}}" wx:key="key">
<view class='df fdc aic mb25 mr44 mw330' bindtap='departmentDetailClick' data-k_id='{{item.k_id}}'> 資料表中是什麼id就寫什麼
<view wx:for="{{item.child}}" wx:for-item="items" >
<image mode='aspectFill' style='width:87rpx;height:87rpx;' src='{{items.k_thumb}}'></image>
</view>
<text class='fs26 c6 mt15'>{{item.k_name}}</text>
</view>
</block>
</view>
JS檔案
departmentDetailClick: function(e) {
console.log(e);
console.log(e.currentTarget.dataset.k_id)
var k_id = e.currentTarget.dataset.k_id
wx.navigateTo({
url: '/hyb_zylxc/department_detail/department_detail?k_id=' + k_id,
})
},