实现方式:
先给el-table一个ref属性 然后获取到这个属性 在mounted阶段执行scrollFun函数,通过setTnterval定时器来实现动态滚动效果,代码如下:
<div class="table">
<div class="table bg”/>
<el-table ref="table":data="protectData" height="198" tooltip-effect="dark">
<el-table-column align="center"prop="name” label="中文名称”show-overflow-tooltip/>
<el-table-column align="center" prop="latinName" label="拉丁名" width="120" show-overflow-tooltip />
<el-table-column align="center"prop="type" label="类别”show-overflow-tooltip/>
<el-table-column align="center"prop="protectLevelTrans”label="国家保护”show-overflow tooltip/>
</el-table>
</div>
mounted()
this.fullscreenHight1()window.addEventListener( 'resize',() =>
this.renderHeight1()
)}
const table = this .$refs .table
const tableRight = this.$refs .tableRight
this.scrollFun(tableRight)
this.scrollFun(table)
}
scrollFun(ref) {
const divData = ref.bodywrapperthis.timer = setInterval(() =>
divData.scrollTop += 1if (divData.clientHeight + divData.scrollTop === divData,scrollHeight) divData.scrollTop = 0
}
},50)
}