思路:elementui裏表格有個height屬性,能給它動態賦值,然後計算一行表格的高度*行數,就是展開之後的高度,在js裏賦值就好了。
<tempate>
<el-table
:data="tableData"
stripe
border
:height="attrHeiht"
style="width: 100%;overflow-y: scroll"
@cell-click="editBtn"
>
<el-table-column type="index"></el-table-column>
</el-table>
</template>
<script>
data(){
return{
attrHeiht:300}
}
// 然後在控制表格的函數中,通過計算一行表格的高度*行數,就是展開之後的高度,摺疊就是給表格高度一個默認值
//表格展開
heightChangeBig(){
this.attrHeiht= 99*this.mediaImgTabledata.length
},
</script>
結果如圖: