当前位置: 首页 > news >正文

vue2项目中滚动的自动和停止

vue2项目中滚动的自动和停止

  • 一、直接上代码

一、直接上代码

<div ref="chatScroll" class="leftReturn">里面好多的内容,这个有滚动条</div>container: null,isUserScrolling: false, //用户是否手动滚动页面scrollFlag: false,//使用that.chcekScroll();that.executeScroll(true 或者 false);updated() {if (!this.container) {this.container = document.querySelector('.leftReturn');}},beforeDestroy() {if (this.container) {this.container.removeEventListener('scroll', () => {if (this.isUserScrolling) {this.scrollFlag = true;} else {this.scrollFlag = false;}});this.container.removeEventListener('wheel', () => {this.isUserScrolling = true;});}},//  判断是否滚动chcekScroll() {this.isUserScrolling = false;this.container.addEventListener('scroll', () => {if (this.isUserScrolling) {this.scrollFlag = true;} else {this.scrollFlag = false;}});this.container.addEventListener('wheel', () => {this.isUserScrolling = true;});},// 输入内容执行滚动效果// scrollFlag:是否执行滚动 true:是,false:否executeScroll(scrollFlag) {if (scrollFlag) {this.$refs.chatScroll.scrollTop =this.$refs.chatScroll.scrollHeight - this.$refs.chatScroll.clientHeight;}},

http://www.mrgr.cn/news/10193.html

相关文章:

  • MonkeyRunner在自动化测试里的应用场景
  • 百度文本内容审核
  • keepalived的技术原理及其在负载均衡场景中的应用
  • RockPI 4A单板Linux 4.4内核下的RK3399 GPIO功能解析
  • PCL-基于RANSAC的平面拟合方法
  • Windows—UDP编程
  • 文件IO
  • [JS]精选面试题-4
  • 买对不买贵,宠物空气净化器应该怎么选才能选到好的产品
  • python的浅拷贝和深拷贝
  • 大模型16:大模型部署ChatGLM-6B
  • 计算机毕业设计推荐-基于python的摄影爱好者分享平台
  • Edge 浏览器插件开发
  • 三种相机模型总结(针孔、鱼眼、全景)
  • git 落后主分支提交
  • 如何有效激活微信陌生客户:加好友后的沟通策略!
  • C语言——函数
  • 66 IPV4/6 OSPFV2/3 实操
  • 会声会影剪辑视频收费吗,会声会影最新破解版
  • ElementUI或AntDesign拿不到对话框内元素的 ref或者dom