时间紧迫,简单写一下
给滑动元素绑定个scroll事件,原生事件是onscroll
<div ref="robot" @scroll="robotScroll">
scroll事件内:当滚动到顶部时将scollTop 设置成1 当到底部时 scrollTop 减去1像素,就是不让元素 到不了顶部或底部
robotScroll(e){ console.log(e); var chatlist = document.getElementsByClassName('robot-box')[0]; // console.log(chatlist.clientHeight); // console.log(chatlist.scrollHeight); // console.log(chatlist.scrollTop); if(chatlist.scrollTop <= 0){ chatlist.scrollTop = 1 } // console.log(`差${chatlist.scrollHeight - chatlist.clientHeight - chatlist.scrollTop}`); if((chatlist.scrollHeight - chatlist.clientHeight - chatlist.scrollTop) <= 0){ chatlist.scrollTop = chatlist.scrollHeight - chatlist.clientHeight - 1; } },
。