Coder Social home page Coder Social logo

vueloadingbar's Introduction

自动给vue-resource的ajax请求添加loadingbar。默认请求时间超过300毫秒才显示,可以手动配置延迟的时间

add loading bar for Vue-resource or axios

vuejs and vue-resource (axios) required;

截图

LoadingBar截图

安装

npm install vueLoadingBar --save

<head>
    ...
    <link href="src/loadingbar.min.css" rel="stylesheet" type="text/css" />
</head>
<body>
    ...
    <script src='src/loadingbar.js'></script>
</body>

or

require('src/loadingbar.js')(Vue);

with webpack

...
import 'vueLoadingBar/src/loadingbar.css';
import Vue from 'vue';
import VueResource from 'vue-resource';
import vueLoadingBar from 'vueLoadingBar';
Vue.use(VueResource);
Vue.use(vueLoadingBar);

注意

如果使用其他支持interceptors的第三方库,需要将第三方库挂载到Vue.http;

使用axios时可以不做任何处理或者绑定到Vue.axios、Vue.$axios

config

loadingBarDelay default 300ms
// 设置请求超过多少毫秒才显示,默认300毫秒
new Vue({...}).loadingBarDelay = 100;
enableLoadingBar default true
// 设置全局禁用loadingbar
new Vue().enableLoadingBar = false;
$hideLoadingBar default false

当前请求禁用loadingbar(不影响其他请求)。只需要在请求的config部分(如axios request)设置$hideLoadingBar为true即可

// 设置此次请求不显示loadingbar
http.get(url, {$hideLoadingBar: true}).then(...); // get
http.post(url, data, {$hideLoadingBar: true}).then(...); // post

vueloadingbar's People

Contributors

douxc avatar dxinchao avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

lampo1024 fay-hu

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.