Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

https://github.com/Sopamo/vue-online

A reactive offline indicator component for vue.js
https://github.com/Sopamo/vue-online

vue vue-component vue2

Last synced: 3 months ago
JSON representation

A reactive offline indicator component for vue.js

Lists

README

        

# vue-online

> A reactive online/offline component for vue.js

![Vue online preview](https://raw.githubusercontent.com/Sopamo/vue-online/master/preview.gif)

# Installation

npm install vue-online --save

# Usage
That's a basic example of a component which would just show the offline message if the user has no connection:






import { OfflineIndicator } from 'vue-online'

export default {
name: 'app',
components: {
OfflineIndicator
}
}

# Advanced usage (with the reactive online variable)

You can use ConnectionStatus.online anywhere in your app, it updates dynamically as the connection of the user changes.



Connection: onlineoffline



import { OfflineIndicator, VueOnline } from 'vue-online'

export default {
name: 'app',
computed: {
online () {
return VueOnline.isOnline
}
},
components: {
OfflineIndicator
}
}

# Custom offline message

To use a custom message, simply specify it on the component:

# Custom styling

To style the offline indicator just use the css selector div.offline-indicator:

div.offline-indicator {
background: red;
color: white;
}