当前位置:首页 > vue.js > 正文内容

vue 项目结构鼠标滑动容器底部

自由小鸟3年前 (2022-09-05)vue.js1518
mounted() {
    this.$nextTick(() => {
      // 进入nexTick
      var bady = document.getElementById("list"); // 在html中设置id为iii的div
      console.log("111list===", bady);
      // console.log("距顶部"+scrollTop+"可视区高度"+windowHeight+"滚动条总高度"+scrollHeight);
      bady.onscroll = () => {
        console.log(1111);
        // 获取距离顶部的距离
        var scrollTop = bady.scrollTop;
        if (scrollTop !== 0 && this.oldv == 0) {
          this.oldv = scrollTop;
        }
        // 获取可视区的高度
        var windowHeight = bady.clientHeight;
        // 获取滚动条的总高度
        var scrollHeight = bady.scrollHeight;
        console.log(
          "距顶部" +
            scrollTop +
            "可视区高度" +
            windowHeight +
            "滚动条总高度" +
            scrollHeight
        );
        if (scrollTop + windowHeight >= scrollHeight) {
          console.log("到达底部了");
        }
        if (scrollTop == 0 && this.oldv !== 0) {
          // console.log("到达头部了");
        }
      };
    });
  },

版权声明:本文由Web学习之路发布,如需转载请注明出处。

本文链接:https://webge.net/?id=148

“vue 项目结构鼠标滑动容器底部” 的相关文章

vue做博客中的问题记录

vue做博客中的问题记录

1,全局变量,统一管理变量文件,路径如:../src/static/css/globle.scss<1>添加依赖 npm install sass-resources-loader --save-dev<2>在项目build文件夹里找到...

vue 公告滑动效果

vue 公告滑动效果

适应只显示一条 <div class="marquee_box"> <ul class="marquee_list" :class="{marquee_top:animate}"> &l...

vue updateModel

vue updateModel

v-model高级用法...

vue 滚动条向下滑动加载更多

<div class="ld-container" id="computer-main" ref="cmdlist"></div> scrollMoreData() { //const scrollT...

vue 用当前对象获取坐标距离

selectMeeting(day, jsEvent) { //jsEvent 这个传进来就是$event this.selectDay = day; this.showMore=false; this.meetingShowMore = true;...