wx:fox 循环2层列表,点击第2层怎么获取父层id?
发布于 6 年前 作者 jyao 1682 次浏览 来自 官方Issues

<view class=“close” data-id="{{item.item.id}}" data-deviation="{{item.id}}" bindtap=“deleteImg”></view> 的 deleteImg事件需要获取deviationlist 的item.id,请问怎么操作

<view class=“deviation-box”  wx:for="{{deviationlist}}" wx:key="{{item.id}}">

<view class=“deviation_title”>

<span class=“title-left”>{{item.id}}{{item.scoreItemNo}} {{item.scoreItemName}}</span>

<span class=“title-right” id="{{item.id}}" bindtap=“deleteDeviation”></span>

<view class=“page-section”>

<view class=“page-section-title”>偏差描述</view>

<view class=“textarea-wrp”>

<textarea value="{{item.describe}}" data-id="{{item.id}}"  bindblur=“bindTextAreaBlur” auto-height bindinput=“saveDescribe” />

</view>

</view>

</view>

<view class=“img_div”>

<view class=“img_list”>

<view class=“camera_box”>

<button class=“camera” data-id="{{item.id}}" bindtap=“choose”>Choose</button>

</view>

<view data-id="{{item.id}}" wx:for="{{item.attachList}}" wx:key="{{item.index}}" class=“option_box”>

<image src="/accessory/download?id={{item.id}}" data-src="/accessory/download?id={{item.id}}" bindtap=‘previewImage’></image>

<view class=“close” data-id="{{item.item.id}}" data-deviation="{{item.id}}" bindtap=“deleteImg”></view>

</view>

</view>

</view>

</view>

2 回复

你给最外层的item重新取下名字,不要跟内部循环重名(wx:for 默认是item和index):

<view wx:for="{{array}}" wx:for-index="idx" wx:for-item="itemName">

 <view wx:for="{{itemName.attachList}}" data-id='{{itemName.id}}'></view>

</view>

循环里边再循环?

回到顶部