Skip to content

oguzsert/vue-component-loading-screen

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

VUE-COMPONENT-LOADING-SCREEN PLUGIN

Vue Component Loading screen is a simple plugin for show an indicator when your component is busy.

  • You can activate/disable loading screens manually
  • You can bind your screen states to [Axios].

Installation

$ npm install vue-component-loading-screen

Demonstration page

$ npm run serve

Implementation

import Vue from 'vue'
import App from './App.vue'
import VueComponentLoadingScreenPlugin from "vue-component-loading-screen";
import "vue-component-loading-screen/vue-component-loading-screen.css";

Vue.use(VueComponentLoadingScreenPlugin,{
  loadingImage:"[YOUR LOADING IMAGE PATH]", //-> Required
  overlayBackgroundColor:"rgba(0,0,0,0.3)" //-> Optional (RGB OR HEX)
});

Manual Screen Activation

export default {
  name: 'HelloWorld',
  methods:{
      exampleMethod(){
          this.COMPONENT_IS_BUSY(); //->Activates loading screen
          /*
          Bunch of code doing something.
          ..................
          ..............................
          .........................................
          */
          this.COMPONENT_IS_IDLE(); // -> Disables loading screen
      }
  }
}

Binding Screen States To Axios Instance

Loading screen activates before request sent and disables when response received or error occured.

import axios from "axios";
export default {
  name: 'HelloWorld',
  methods:{
    sendAjax(){
        var yourAxiosInstance = axios.create({
              baseURL: '[SOME API PATH]'
        });
        this.bindLoadingScreenToAxios(yourAxiosInstance);
        yourAxiosInstance();
    }
  }
}

OPTIONS

Option Description Is Required Default Value
loadingImage Path of your loading image true -
overlayBackgroundColor Loading screen background color. You can set HEX or RGB value false rgba(0,0,0,0.5)
License

MIT

About

A simple plugin for show an indicator when your component is busy

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published