<template>
<div class="consoleBox">
<div class="curentScroll" v-for="(item,index) in debugProcessList" :key="index" style="line-height: 30px;">{{item.createTime}} {{item.content}}</div>
</div>
</template>
export default {
name: 'parkScreen',
data() {
return {
oldScrollTop:0,
scrollFlag:true,
}
},
mounted() {
var that = this;
document.querySelector(".consoleBox").addEventListener('scroll',this.scrolling)
this.getUpdataData()
},
methods: {
getUpdataData(){
let that=this
let robotId=1
getDebugRecord({tobotId:robotId}).then(res => {
if(res.rows.length>0){
that.debugProcessList=[]
that.debugProcessList=res.rows
}
})
if(this.scrollFlag){
this.scrollToBottom();
}
},
scrollToBottom () {
this.$nextTick(() => {
var container = this.$el.querySelector(".consoleBox");
container.scrollTop = container.scrollHeight;
})
},
scrolling() {
let scrollTop = document.querySelector(".consoleBox").scrollTop
let scrollStep = scrollTop - this.oldScrollTop;
this.oldScrollTop = scrollTop;
if (scrollStep < 0) {
this.scrollFlag=false
}else{
this.scrollFlag=true
}
},
}