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
}