Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

vue-loading-overlay

Package Overview
Dependencies
Maintainers
1
Versions
40
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vue-loading-overlay

Vue.js v2.x component for full screen loading indicator

  • 2.0.4
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
53K
increased by1.94%
Maintainers
1
Weekly downloads
 
Created
Source

Vue Loading Overlay Component

vue-js downloads npm-version github-tag license

Vue.js v2.x component for full screen loading indicator

Demo on JSFiddle

Installation

:mega: Now published to npm

# npm
npm install vue-loading-overlay --save

# Yarn
yarn add vue-loading-overlay

Usage

As component
<template>
    <div>
        <loading :active.sync="isLoading" :can-cancel="true" :on-cancel="whenCancelled"></loading>
        <button @click.prevent="fetchData">fetch Data</button>
    </div>
</template>

<script>
    // Import component
    import Loading from 'vue-loading-overlay';
    // Import stylesheet
    import 'vue-loading-overlay/dist/vue-loading.min.css';

    export default {
        data() {
            return {
                isLoading: false,
            }
        },
        components: {
            Loading
        },
        methods: {
            fetchData() {
                this.isLoading = true;
                // AJAX example with axios
                axios.post('/api').then((response)=>{
                  this.isLoading = false                
                })
            },
            whenCancelled() {
              console.log("User cancelled the loader.")
            }
        }
    }
</script>

As plugin

<template>
    <form @submit.prevent="submit">
        <!-- form inputs -->
    </form>
</template>

<script>
    import Vue from 'vue';
    // Import component
    import Loading from 'vue-loading-overlay';
    // Import stylesheet
    import 'vue-loading-overlay/dist/vue-loading.min.css';
    // Init plugin
    Vue.use(Loading);

    export default {
        methods: {
            submit() {
                let loader = this.$loading.show();
                axios.post('/api').then((response)=>{
                  loader.hide()
                })                 
            }
        }
    }
</script>

Available props

The component accepts these props:

AttributeTypeDefaultDescription
canCancelBooleanfalseAllow user to cancel
onCancelFunction()=>{}Do something upon cancel

Install in non-module environments (without webpack)

<!-- Vue js -->
<script src="https://unpkg.com/vue@2.5/dist/vue.min.js"></script>
<!-- Lastly add this package -->
<script src="https://unpkg.com/vue-loading-overlay@2"></script>
<link href="https://unpkg.com/vue-loading-overlay@latest/dist/vue-loading.min.css" rel="stylesheet">
<!-- Init the plugin -->
<script>
Vue.use(VueLoading)
</script>

Run examples on your localhost

  • Clone this repo
  • Make sure you have node-js >=6.10 and yarn >=1.x pre-installed
  • Install dependencies - yarn install
  • Run webpack dev server - yarn start
  • This should open the demo page at http://localhost:9000 in your default web browser

Browser support

  • I have not taken care of old browsers.
  • You can apply autoprefixer on css to support older browsers.

Credits

License

MIT License

Keywords

FAQs

Package last updated on 23 Mar 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc