WeChat Mini Programs launches the two buttons separately. How can they not interfere with each other?

there are two buttons An and B, and there are c and d in A

             Be  f   
             

now the situation is that press A, B will expand
press B, A will also expand

wxml

<view class="bg-white" wx:for="{{ dataInfo }}" wx:key="item">
    <view class="data-info" data-idx="{{ index }}" bindtap="expandDetail">

        <view>
            <button class="aaa" disabled="{{disabled}}" bindtap="submit">

                <text>AAA</text>
            </button>
        </view>
    </view>





    <!--  -->
    <view class="data-expand p10 border-bottom" wx:if="{{ item.flag }}">
        <button class="ccc" type="warn">ccc</button>
        <button class="ddd" type="warn">ddd</button>
    </view>

</view>




<view class="bg-white" wx:for="{{ dataInfo }}" wx:key="item">
    <view class="data-info" data-idx="{{ index }}" bindtap="expandDetail">

        <view>
            <button class="bbb" disabled="{{disabled}}" bindtap="submit">

                <text>BBB</text>
            </button>
        </view>
    </view>





    <!--  -->
    <view class="data-expand p10 border-bottom" wx:if="{{ item.flag }}">
        <button class="eee" type="warn">eee</button>
        <button class="fff" type="warn">fff</button>
    </view>

</view>

js
Page({


  data: {
    
    tempInfo: [{ // 

    }, ],
    dataInfo: [], // 

    

  },






  expandDetail: function (e) {
    var idx = e.currentTarget.dataset.idx, // 
        key = "dataInfo[" + idx + "].flag",
        val = this.data.dataInfo[idx].flag;
    this.setData({
      [key]: !val
    });
  },


  onLoad: function(opt) {
    for (var i in this.data.tempInfo) {
      this.data.tempInfo[i].flag = false; // 
    };
    this.setData({
      dataInfo: this.data.tempInfo
    });
  },



})





Jun.08,2022

you can add specific button identifiers to expandDetail . Then use the corresponding item.flag control.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b348c2-2b69d.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b348c2-2b69d.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?