Giter VIP home page Giter VIP logo

vue-scroll's Introduction

vue-scroll

Usage

Use:

<template>
  <div>
    <my-scroll ref="myScroll" :on-refresh="onRefresh" :on-pull="onPull" :get-scroll-top="getTop" :scroll-state="scrollState">
					<div slot="scrollList">
            <!-- 列表 -->
					</div>
		</my-scroll>
  </div>
</template>
<script>

import myScroll from "vue-scroll.vue";

new Vue({
  el: '#app',
  data(){
    return{
      scrollState: true, //是否可以滑动
      indexScrollTop:0,
      listdata:[]
    }
  },
  components: {
    myScroll
  },
  methods:{
        onRefresh(mun) { // 刷新
            this.listParams.p = 1;
            this.$axios
                .get(apiUrl.noticeList, {
                    params: this.listParams,
                    isLoading: false
                })
                .then(res => {
                    if (res.code == 10000) {
                        this.listParams.p++;
                        this.listdata = res.data;
                        this.$refs.myScroll.setState(3);
                    } else {
                        this.$refs.myScroll.setState(3);
                    }
                });
        },
        onPull(mun) { //加载
            this.$axios
                .get(apiUrl.noticeList, {
                    params: this.listParams,
                    isLoading: false
                })
                .then(res => {
                    if (res.code == 10000 && res.data.length > 0) {
                        this.listParams.p++;
                        res.data.map((v, k) => {
                            this.listdata.push(v);
                        });
                        this.$refs.myScroll.setState(5);
                    } else {
                        this.$refs.myScroll.setState(7);
                    }
                });
        },
        getTop(y) {//滚动条位置
            this.indexScrollTop = y;
        },
  },
});
</script>

Options

Props

Props Type Default Description
page Object auto counter:当前页 pageStart:开始页数 pageEnd:结束页数 total:总页数
onRefresh Function true 刷新回调
onPull Function true 加载回调
getScrollTop Function auto 获取滚动条位置
scrollState Boolean true 获取滚动条位置

Function

Name Type Description
setState Number setState(状态) 刷新中:1 松开刷新:2 刷新完成:3加载中:4 加载完成:5 下拉刷新:6 没有更多:7
setScrollTop Number setScrollTop(滚动条位置)

Screenshot

vue-scroll's People

Contributors

fzliweiliang avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.