Giter Site home page Giter Site logo

vpull-refresh's Introduction

vpull-refresh

基于vue封装的轻量级下拉刷新组件

如何使用

将项目中的src/components/pullRefresh.vuesrc/img拷贝到你的工程内。如层级发生改变,你需要手动修改pullRefresh.vue中的图片链接地址。

API

属性 说明 类型 默认值
refreshing 是否处于刷新状态 boolean false
onRefresh 刷新的回调函数 function () => {}
tipHeight 刷新提示信息的高度 string 50px
pullHeight 滚动区域高度 string 100vh
pullTip 下拉时的提示文字 string 下拉即可刷新
refreshTip 刷新中的提示文字 string 正在刷新

示例

<template>
<pull-refresh :refreshing="isRefreshing" :on-refresh="onRefresh" pull-height="400px">
  <div class="list">
    <p v-for="n in 20">{{n}}</p>
  </div>
</pull-refresh>
</template>

<script>
import pullRefresh from "@/components/pullRefresh.vue";
  export default  {
    name: 'Example',
    data() {
      return {
        isRefreshing: false
      }
    },
    methods: {
      onRefresh() {
        //刷新前需要先手动将设为true,否则pull-refresh不会监测到状态变化
        this.isRefreshing = true;
        setTimeout(() => {
          this.isRefreshing = false;
        }, 2000)
      }
    },
    components: { pullRefresh }
}
</script>

<style scoped>
.list {
  background-color: white;
}
p {
  margin: 0;
}
</style>

手动刷新

<pull-refresh :refreshing="isRefreshing">
  <div class="list">
    <button @click="onRefresh">手动刷新</button>
    <p v-for="n in 20">{{n}}</p>
  </div>
</pull-refresh>

vpull-refresh's People

Contributors

mescalchuan avatar

Watchers

James Cloos 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.