vue-component-loading-screen

a simple plugin for show an indicator when your component is busy.

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

Implementation

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

Vue.use(VueComponentLoading,{
  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

HomePage

https://github.com/oguzsert/vue-component-loading-screen#readme

Repository

git+https://github.com/oguzsert/vue-component-loading-screen.git


上一篇:custom-guider
下一篇:centis

相关推荐

公众号

欢迎 JavaScript 爱好者