Two buttons control the display and hiding of the same piece of content

problem description

in a table, there are two buttons that can be clicked to control the display and hiding of the expanded rows of the table, and the two buttons can switch between different contents

the environmental background of the problems and what methods you have tried

Click button 1, and then click button 2 to switch different content. Div is not hidden. Div is hidden when I click button 2, but when I click button 1 again, there is no response. I need to click again to show the content

related codes

<el-table-column label="" prop="release_status">
        <template slot-scope="props">
          <div class="release_status" @click="addExpand(props.row)">
            
          </div>
        </template>
      </el-table-column>
      <el-table-column type="expand">
        <template slot-scope="props">
          <div v-if="status === 0">
            <span></span>
          </div>
          <div v-else>
            <span></span>
          </div>
        </template>
      </el-table-column>
      <el-table-column label="" prop="trade_status">
        <template slot-scope="props">
          <div class="trade_status" @click="addAgainExpand(props.row)">
            
          </div>
        </template>
      </el-table-column>

methods method:

    let flag = true
    let status = 1
    addExpand(row) {
      this.status = 0
      const $table = this.$refs.table
      if (flag) {
        $table.toggleRowExpansion(row, true)
        status = 1
      } else {
        if (status === 1) {
          $table.toggleRowExpansion(row, false)
          status = 2
        } else {
          $table.toggleRowExpansion(row, true)
          status = 1
        }
      }
      flag = !flag
    },
    addAgainExpand(row) {
      this.status = 1
      const $table = this.$refs.table
      if (!flag) {
        $table.toggleRowExpansion(row, true)
        status = 2
      } else {
        if (status === 2) {
          $table.toggleRowExpansion(row, false)
          status = 1
        } else {
          $table.toggleRowExpansion(row, true)
          status = 2
        }
      }
      flag = !flag
    }


I don't know if I understand this correctly: different buttons correspond to different expansion content, and the second click hides the expansion element only when the corresponding expansion content is displayed.

if I understand it correctly, I only need to set a state to store the state of the expanded element. 0 means hidden, 1 shows expanded content 1, and 2 indicates expanded content 2. The button's click logic first determines whether the state is 0 , and if so, writes 1 or 2 , otherwise 0 . The explicit and implicit control of the expanded element only determines whether the state is 0 .

I think your code is a little complicated.

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-1bdc3c0-312ed.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-1bdc3c0-312ed.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?