You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

vue-offline

Package Overview
Dependencies
Maintainers
1
Versions
26
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vue-offline

Oline/Offlien states for vue applicationnne[

1.0.0
Source
npmnpm
Version published
Weekly downloads
1.6K
-18.18%
Maintainers
1
Weekly downloads
 
Created
Source

License: MIT

Offline/online states for Vue applications

This plugins notifies your application when online/offline status changes and allows to conditionally display components depending on the network status.

Installation

npm install vue-offline --save
import Vue from 'vue'
import VueOffline from 'vue-offline'

Vue.use(VueOffline)

Features

  • v-online directive - shows component only when online
  • v-offline directive - shows component only when offline
  • online event - available in every component, emitted when user changes from offline to online
  • offline event - available in every component, emitted when user changes from online to offline

Example

<template>
  <div id="app">
    <div v-online>This part is visible only when user is online</div>
    <div v-offline>This part is visible only if user is offline</div>
    <div> {{ onlineState }} </div>
  </div>
</template>

<script>
export default {
  data () {
    return {
      onlineState: navigator.onLine
    }
  },
  created () {
    this.$on('online', function () {
      this.onlineState = "I'm online now!" 
    })
    this.$on('offline', function () {
      this.onlineState = "I'm offline now!"
    })
  }
}
</script>

Keywords

pwa

FAQs

Package last updated on 02 Apr 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