1.父元素定义ref,子元素设置动态高度
//ref 加在普通的元素上,用this. r e f s . ( r e f 值 ) 获 取 到 的 是 d o m 元 素 / / refs.(ref值) 获取到的是dom元素 // refs.(ref值)获取到的是dom元素//nextTick 在DOM更新后自动调用
<div style="height:100%" ref="tableHeght">
<Table border stripe :columns="columns" :data="tableData" :height="tableHeight">
<template slot-scope="{row}" slot="action">
<a @click="updata(row)">修改</a>
<a @click="deletes(row)"> 删除</a>
</template>
</Table>
</div>
2.在初始化函数或者监听函数中使用
mounted() {
//计算table的高度
this.$nextTick(() => {
let tableHeight = this.$refs.tableHeght.offsetHeight;
this.tableHeight= tableHeight ;
});
},