小程序 点击切换
itemidClicked: function(e) { var v = e.currentTarget.dataset.itemid if (v != itemidClicked) { itemidToggle = true } else { itemidToggle = !itemidToggle } itemidClicked = v var that = this; that.setData({ itemidClicked: itemidClicked, itemidToggle: itemidToggle }); }, <view wx:for="{{item.medias}}" style="display:{{item.package_id===itemidClicked && itemidToggle ? 'block':'none' }}" wx:for-item="itemsSecond"> {{itemsSecond.media_name}}{{itemsSecond.media_id}} </view>