vue 鼠标滚动 加载组件_vue.js的滚动加载组件

Vue-scroll-loader是一款适用于vue.js的滚动加载组件,可通过NPM或CDN安装,使用特定props定义加载选项。当组件底部触及视口底部时,会执行预设的加载方法。
摘要由CSDN通过智能技术生成

vue 鼠标滚动 加载组件

Vue-scroll-loader (vue-scroll-loader)

A scroll loading component for vue.js.

vue.js的滚动加载组件。

安装 (Install)

NPM

NPM

npm install vue-scroll-loader

CDN

CDN

<script src="https://unpkg.com/vue-scroll-loader"></script>

用法 (Usage)

Use <scroll-loader/> to enable the scroll load, and use loader-* props to define its options.

使用<scroll-loader/>启用滚动加载,并使用loader- * props定义其选项。

The method appointed as the props of loader-method will be executed when the bottom of the scroll-loader reaches the bottom of the viewport.

当滚动加载器的底部到达视口底部时,将执行指定为加载器方法属性的方法

<scroll-loader :loader-method="getImagesInfo" :loader-enable="loadMore">
</scroll-loader>

<!-- Replace the default loading animation with slot -->
<scroll-loader :loader-method="getImagesInfo" :loader-enable="loadMore">
    <div>Loading...</div>
</scroll-loader>
import Vue from 'vue'
import ScrollLoader from 'vue-scroll-loader'

Vue.use(ScrollLoader)

new Vue({
    el: '#app',
    data() {
      return {
        loadMore: true,
        page: 1,
        pageSize: 9,
        images: [],
      }
    },
    methods: {
      getImagesInfo() {
        axios.get('https://api.example.com/', {
            params: {
              page: this.page++,
              per_page: this.pageSize,
            }
          })
          .then(res => {
            this.images.concat(res.data)
            
            // Stop scroll-loader
            res.data.length < this.pageSize && (this.loadMore = false)
          })
          .catch(error => {
            console.log(error);
          })
      }
    },
    mounted() {
      this.getImagesInfo()
    }
  })

选件 (Options)

PropsDescriptionRequiredTypeDefault
loader-methodScrolling to the bottom to execute the methodtrueFunction--
loader-enableScroll-loader will be disabled if the value of this props is false.trueBoolean--
loder-throttleCheck the frequency of scrolling to the bottom (ms)falseNumber100
loader-distanceThe minimum distance between the bottom of the scroll-loader and the bottom of the viewport before the ":loader-method" method is executed.falseNumber0
loader-colorscroll-loader the color of the animationfalseString#96C8FF
loader-sizescroll-loader the size of the animationfalseString35px
道具 描述 需要 类型 默认
加载器方法 滚动到底部以执行该方法 真正 功能 -
启用加载程序 如果此props的值为false,则将禁用滚动加载器。 真正 布尔型 -
油门节气门 检查滚动到底部的频率(毫秒) 100
装载距离 在执行“:loader-method”方法之前,滚动加载器的底部与视口底部之间的最小距离。 0
装载机颜色 滚动加载器动画的颜色 #96C8FF
装载机尺寸 滚动加载器动画的大小 35像素

翻译自: https://vuejsexamples.com/a-scroll-loading-component-for-vue-js/

vue 鼠标滚动 加载组件

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值