Socket
Socket
Sign inDemoInstall

vue-super-scroller

Package Overview
Dependencies
Maintainers
1
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vue-super-scroller

基于vue 2.0 上下拉组件


Version published
Weekly downloads
3
decreased by-25%
Maintainers
1
Weekly downloads
 
Created
Source

vue-super-scroller

npm npm vue2

Table of contents

Installation

npm install vue-super-scroller --save

Global Install

Install all the components:

import Vue from 'vue'
import VueSuperScroller from 'vue-super-scroller'

Vue.use(VueSuperScroller)

Usage

:load-disabled="!hasNext"

:on-refresh="refresh"

:on-load='loadMore'

Example

<template>
  <div id="app">
    <vue-scroller :load-disabled="!hasNext" :on-refresh="refresh" :on-load='loadMore'>
      <li v-for="(item,index) in lists">{{item}}</li>
    </vue-scroller>
  </div>
</template>

<script>
  export default {
    name: 'app',
    components: {},
    data () {
      return {
        lists: [1, 2, 3],
        hasNext: true
      }
    },
    mounted () {
      this.$nextTick(function () {
        this.loadMore()
      })
    },
    methods: {
      getRandArr (num = 20) {
        let arr = []
        for (let i = num - 1; i >= 0; i--) {
          arr.push(Math.round(Math.random() * 100))
        }
        return arr
      },

      refresh (call) {
        setTimeout(() => {
          this.lists = [1, 2, 3]
          call(true)
        }, 1000)
      },

      loadMore () {
        setTimeout(() => {
          this.lists = this.lists.concat(this.getRandArr(20))
          if (this.lists.length > 50) {
            this.hasNext = false
          }
        }, 1000)
      }
    }
  }
</script>

<style>
  #app {
    font-family: 'Avenir', Helvetica, Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-align: center;
    color: #2c3e50;
    margin-top: 60px;
  }

  li {
    height: 150px;
    text-align: center;
    line-height: 150px;
    font-size: 30px;
  }

  li:nth-child(odd) {
    background-color: #eee
  }
</style>

License

MIT

FAQs

Package last updated on 11 Jan 2017

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc