鸳鸯亭资源网 Design By www.gvabc.com
背景
做管理平台的项目,用到了element-ui,需要通过监听el-table滚动的位置来获取最新的数据,那么怎么样监听el-table的滚动呢?
准备
我们默认的技术栈是 vue+element-ui
template代码:
<el-table :data="logList" :show-header="false" row-class-name="table-row-class" height="700" ref="table" @row-click="rowClick"> <el-table-column type="expand"> <el-table-column label="log信息" prop="message"> </el-table-column> </el-table>
绑定监听事件
mounted() { // 获取需要绑定的table this.dom = this.$refs.table.bodyWrapper this.dom.addEventListener('scroll', () => { // 滚动距离 let scrollTop = this.dom.scrollTop // 变量windowHeight是可视区的高度 let windowHeight = this.dom.clientHeight || this.dom.clientHeight // 变量scrollHeight是滚动条的总高度 let scrollHeight = this.dom.scrollHeight || this.dom.scrollHeight if (scrollTop + windowHeight === scrollHeight) { // 获取到的不是全部数据 当滚动到底部 继续获取新的数据 if (!this.allData) this.getMoreLog() console.log('scrollTop', scrollTop + 'windowHeight', windowHeight + 'scrollHeight', scrollHeight) } }) }
获取到新的数据后,调整滚动条的位置
getMoreLog() { ... this.dom.scrollTop = this.dom.scrollTop - 100 ... }
结语
至此我们已经完成了对table的绑定! 希望对大家的学习有所帮助,也希望大家多多支持。
鸳鸯亭资源网 Design By www.gvabc.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
鸳鸯亭资源网 Design By www.gvabc.com
暂无评论...
更新日志
2024年09月23日
2024年09月23日
- 华少翌.2005-华少翌【中唱艺能】【WAV+CUE】
- 群星《十二女声Ⅱ》[WAV/CUE/分轨][527MB]
- 大自然音乐系列《漫步在山裡》[WAV/CUE/分轨][502.8MB]
- 大自然音乐系列《星光夜语》[WAV/CUE/分轨][453.3MB]
- 史依弘《史依弘交响乐京剧演唱专辑HQ》头版限量编号[WAV+CUE]
- 曼丽2020《女人三十风继续吹》HQCD[WAV+CUE]
- 曼丽2021《女人三十2雾之恋》HQCD[WAV+CUE]
- 隔壁老樊.2019-我曾【好听音乐】【FLAC分轨】
- 高林生.1993-牵挂你的人是我【白天鹅】【WAV+CUE】
- 洪卓立.2012-找个懂我的女孩(国专)【英皇娱乐】【WAV+CUE】
- 曼丽2022《女人三十3晚秋》HQCD[WAV+CUE]
- 曼丽2018《女人三十4冬天》HQCD[WAV+CUE]
- 柏菲-《好歌30年壹》限量开盘母带ORMCD[低速原抓WAV+CUE]
- 大自然音乐系列《水舞》[WAV/CUE/分轨][424.3MB]
- 大自然音乐系列《鲸声奇遇》[WAV/CUE/分轨][566.8MB]