🎩 You're Invited:Meet the Socket team at Black Hat in Las Vegas, August 3-6.RSVP
Sign In

vue-scroload

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vue-scroload

scroll load component for vue

latest
npmnpm
Version
1.0.8
Version published
Weekly downloads
16
166.67%
Maintainers
1
Weekly downloads
 
Created
Source

vue-scroload

scroll load component for vue

vue-scroload 使用IntersectionObserver做的一个下拉加载组件

@scollCallBack: 组件滚动到底部时的回调,用于异步加载列表数据

:loadText: 组件滚动到底部时显示的内容,也可以使用slot(name: load) 自定义

:nomoreText: 没有更多数据时的显示内容,也可以使用slot(name: nomore) 自定义

:nomoreData: true表示没有更多数据,不再执行回调

Build Setup

# install dependencies
npm install

# serve with hot reload at localhost:8080
npm run dev

# build for production with minification
npm run build

Doc

# install dependencies
npm install vue-scroload --save


// examples 1: main.js
// import scroload from './lib/index.js'
// vue.use(scroload.vueScrollLoad)

// examples 2:
<template>
  <div class="contaner">
    <div v-for="(n, i) in imgList" :key="i" :style="{backgroundColor: bgColor()}" class="load-item">{{i + '-' + n}}</div>
    <vue-scroload
      @scollCallBack="loadList"
      :nomoreText="'没有更多数据了'"
      :nomoreData="nomore"
      :loadText="'加载中...'">
      <!-- you can add slot for loadText name:load -->
      <!-- you can add slot for nomoreText name:nomore -->
    </vue-scroload>
  </div>
</template>

<script>
import scroload from 'vue-scroload'

export default {
  name: 'app',
  data () {
    return {
      imgList: [1, 2, 3, 4, 5, 6],
      nomore: false
    }
  },
  components: {
    'vue-scroload': scroload
  },
  methods: {
    bgColor () {
      return '#' + Math.floor(Math.random() * 0xffffff).toString(16)
    },
    loadList () {
      setTimeout(() => {
        if (this.imgList.length < 30) {
          this.imgList = this.imgList.concat([1, 2, 3, 4, 5, 6])
        } else {
          this.nomore = true
        }
      }, 1000)
    }
  }
}
</script>

For detailed explanation on how things work, consult the docs for vue-loader.

FAQs

Package last updated on 21 May 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts