vue瀑布流组件vue-waterfall-easy的使用

news/2024/7/9 23:55:47 标签: js, html, vue
htmledit_views">

1、安装vue-waterfall-easy组件

npm install vue-waterfall-easy --save-dev

2、在所需要使用的页面中引入该组件并编写相关业务逻辑代码

<template>
    <div>
    <vue-waterfall-easy v-show="!noData&&loadingShow" ref="waterfall" @scrollReachBottom="getData" :imgsArr="imgsArr" :loadingDotCount="3" :loadingDotStyle="{backgroundColor:'#29C694'}" :mobileGap="12" :style="{height:wrapheight+'px'}" :reachBottomDistance="15" @click="jump">
    <div class="img-info" slot-scope="props">
        <!-- <p class="readNum">{{list[props.index].readNum}}人浏览</p> -->
        <p class="some-info">{{list[props.index].title}}</p>
        <div class="some-class">
          <div class="item" v-show="list[props.index].topicTitle"><img src="../../static/images/title.png" alt="">{{list[props.index].topicTitle}}</div>
          <div class="item" v-show="list[props.index].sqTagList.length>0" v-for="sqTagListItem in list[props.index].sqTagList">{{sqTagListItem.title}}</div>
        </div>
        <div class="userInfo">
          <div class="userInfo_header">
            <img :src="list[props.index].portrait" alt="">
            <img src="../../static/images/vip.png" alt="" class="vipPic">
          </div>
          <div class="name">{{list[props.index].author}}</div>
        </div>
    </div>
    <div slot="waterfall-over" v-if="" class="allLoad">没有更多内容了~</div>
</vue-waterfall-easy>
    </div>
</template>
<script>
    import vueWaterfallEasy from 'vue-waterfall-easy';
   export default {
       name:'celebrity',
       components:{
           vueWaterfallEasy
       },
       methods:{
           getCircleArticleCollect(status){
              let _this=this;
              if(_this.allLoaded){
                return false;
              }
              $http.get(
                 apiUrl.celebrity,
                 {pageNum:this.currPage,pageSize:utils.pageSize,queryType:2},
                 {Authorization:this.token})
              .then(data => {
                let {code,data:resdata} = data;
                if(code == 200) {
                  _this.loadingShow=true;
                  if(resdata.list.length == 0) {
                      this.noData = true;
                      return;
                  }
                  resdata.list.forEach(element => {
                    let theHref='javascript:'+element.extTypes+';';
                    _this.imgsArr.push({src:element.img,href:theHref});
                  });
                  
                  this.list=this.list.concat(...resdata.list);
                  this.totalCount=resdata.totalCount;
                  if(resdata.totalCount == this.list.length) {
                      //由于数据请求完和数据加载完有时间误差,所以经常会出现问题
                      //1、请求判断没有更多数据的时候,阻止上拉加载更多的行为
                      //2、判断DOM如果都加载完的话,就显示默认的那个加载完的提示
                    this.allLoaded=true;     //先阻止上拉加载更多
                    var timer=setInterval(function(){
                      var DomLength=document.querySelector('.vue-waterfall-easy').querySelectorAll('.img-box').length;
                      if(DomLength==resdata.totalCount){       
                        _this.$refs.waterfall.waterfallOver();   //在定时器中判断如果数据加载完了,就显示加载完的提示
                        clearInterval(timer);
                      }
                    },100);
                  }
                } else {
                  Toast(utils.toastconfig(data.msg));
                }
               },err=>{
                  Toast(utils.toastconfig(err.msg)); 
              })
            }
           }
       }
   }
</script>

 


http://www.niftyadmin.cn/n/1385450.html

相关文章

从「林」开始: imx51-linux-webserver(goAhead 2.5)

///从「林」开始&#xff1a; imx51-linux-webserver(goAhead 2.5)/ ///environment&#xff1a;// compile system&#xff1a;Ubantu 10.04 // target system&#xff1a; imx51 // resource: webs-2-5.tar.gz// reference: http://blog.…

SQLite数据库存储数据

来自为知笔记(Wiz)转载于:https://www.cnblogs.com/lzqbk/p/4aa7e4f081b839839ffba3fda79583e7.html

服务网关 Spring Cloud Zuul

(git上的源码&#xff1a;https://gitee.com/rain7564/spring_microservices_study/tree/master/fifth-spring-cloud-zuul) 对于服务网关是什么、有什么用&#xff1f;使用API Gateway这篇文章已经讲得很清楚了&#xff0c;这里就不再赘述。当然这只是翻译版&#xff0c;原版在…

Network --- Tcp Protocol

转载于:https://www.cnblogs.com/zhongzhiqiang/p/5792627.html

css3设置图片自适应缩放

object-fit: cover; <div class"theImg"><img src"../assets/img/img1.jpg"> </div> <style> .theImg{width: 200px;height: 200px; } .theImg>img{width: 100%;height: 100%;object-fit: cover; } </style>

The Little Prince-12/12

The Little Prince-12/12 双十二&#xff0c;大家有没有买买买呢&#xff1f;宝宝双十一之后就吃土了&#xff0c;到现在&#xff0c;叶子都长出来了&#xff01;&#xff01;&#xff01; 当你真的喜欢一个人的时候 就会想很多 会很容易办蠢事 说傻话小王子要离开狐狸了。 ——…

Hive 数据库仓库的基本操作

Hive 数据库仓库的基本操作查看hive中的数据库Show databases&#xff1b;查看hive中的表Show tables&#xff1b;查看表结构信息DESCRIBE table_name;创建表&#xff1a;CREATE TABLE daxiong (id INT, name STRING);创建一个新表daxiong1&#xff0c;结构与daxiong一样Create…

生活中的享受

我们于日用必需的东西以外&#xff0c;必须还有一点无用的游戏与享乐&#xff0c;生活才觉得有意思。我们看夕阳&#xff0c;看秋河&#xff0c;看花&#xff0c;听雨&#xff0c;闻香&#xff0c;喝不求解渴的酒&#xff0c;吃不求饱的点心&#xff0c;都是生活上必要的——虽…