思路: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>
结果如图: