Giter Site home page Giter Site logo

request-loading's Introduction

request-loading

基于 TypeScript 开发的 HTTP 请求 Loading 动画插件,主要用于延迟展示 Loading 和防止重复点击。

延迟展示 Loading,短时间内的请求不展示 Loading,当请求时间达到某个阈值(默认 500ms),则展示 Loading,为了防止 Loading 闪烁,做了最少展示时间处理。 防重复点击,当调用 Loading show 时,则先展示透明遮罩,用于阻止用户点击,Loading hide 时,则移除该遮罩。

安装

# 使用npm
npm i -S request-loading
# 使用yarn
yarn add request-loading

运行项目示例

cd ./example
npm install
npm run dev

用法

// 需要引入全局样式
import Loading from 'request-loading'
import 'request-loading/dist/index.css'

Loading.show()

http.get('/user/info').then(() => {
  Loading.hide()
})

方法

  • setConfig(options) 你可以设置 Loading 的配置,来达到更理想的效果
参数 类型 必填项 默认 说明
zIndex number 9999 指定 loadin 层级
delay number 500 延迟展示 loading 的时间
icon string 'default'、'dot'、 'bar' 默认提供三种 Loading 动画
iconTemplate string -- 设置自定义 icon 模版
  • show Loading 展示调用

  • hide 关闭 Loading 调用

License

MIT

request-loading's People

Stargazers

test avatar

Watchers

test 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.