Giter Club home page Giter Club logo

vue-loading's Introduction

crip-vue-loading

A Vue.js project to wrap axios and display global loading bar of http requests. For more details read documentation with examples

Usage

Install

> npm i -S crip-vue-loading

Setup

import Vue from "vue"
import CripLoading from "crip-vue-loading"
import axios from "axios"

// Install component in to Vue instance and inject in to axios.
Vue.use(CripLoading, {axios})

// If you use "vue-router" and do not disable `applyOnRouter` option
// make sure you install plugin before router:
// https://github.com/vuejs/vue-router/issues/315

Display loading bar

// App.vue
<template>
  <div class="container">

    <div class="row">
      <div class="col-lg-6 col-lg-offset-3 col-md-8 col-md-offset-2">
        <button class="btn btn-primary" @click="save($event, 2)">Save</button>
      </div>
    </div>

  </div>
</template>

<script>
  import axios from 'axios'
  
  export default {
    methods: {
      async save (e, timeout = 0) {
        try {
          // simply call axios to save or request data and loading bar will
          // show up while response is not received from server.
          await axios.get(`http://www.fakeresponse.com/api/?sleep=${timeout}`)
        } catch (err) {
          console.error(err)
        }
      },
    },
  }
</script>

TODO:

  • Add algorithm with exponential progression instead of current linear;

Build Setup

# install dependencies and serve with hot reload at localhost:8080
> npm i && npm run dev

Release steps

> npm run release

vue-loading's People

Contributors

tahq69 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

vue-loading's Issues

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.