1.wxml(可以使用navigator标签,获取当前id数据)
<view class="add">
<block wx:for="{{goodslog}}">
<view class="add1">
<navigator url="/pages/desn/desn?id={{item.id}}">
<image class="pic" src="/img/456.webp" style="width: 390rpx; height: 390rpx;"></image>
</navigator>
<text style="font-size: 20px;">{{item.name}}</text>
<text style="color: red;">{{item.price}}元</text>
</view>
</block>
</view>
2.详情页面中的js页面中,获取当前id并传入数据库中
onLoad: function (options) {
console.log(options.id);
let id = options.id
wx.request({
url: 'http://www.tp.com/index.php/etc', //仅为示例,并非真实的接口地址
data: {
id:id
},
header: {
'content-type': 'application/json' // 默认值
},
success (res) {
console.log(res.data)
}
})