Vue.component('table-ranking-material', { template:`
`, props: { height:{ type:Number }, data: { type:Object, }, }, data() { return { interval: '', }; }, mounted(){ this.init() }, created() { }, methods: { init() { //表格定时器 this.interval = setInterval(this.scroll, 50); }, scroll() { let maxHeight = this.$refs.warning.$el.querySelectorAll('.el-table__body')[0].offsetHeight; let clientHeight = this.$refs.warning.bodyWrapper.clientHeight; if (Math.abs(this.$refs.warning.bodyWrapper.scrollTop - (maxHeight - clientHeight)) < 3) { //预留5像素误差 this.$refs.warning.bodyWrapper.scrollTop = 0; } else { this.$refs.warning.bodyWrapper.scrollTop += 1;//32是每一行表格的高度,每秒滚一行 } }, //鼠标移入停止滚动 mouseEnter() { clearInterval(this.interval); }, //鼠标离开继续滚动 mouseLeave() { this.interval = setInterval(this.scroll, 50); }, onRankingTr(row){ this.$emit('item',row); } }, watch:{ data:function () { this.init() } } })