Ecosyste.ms: Awesome

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

Awesome Lists | Featured Topics | Projects

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: about 9 hours ago
JSON representation

A reactive offline indicator component for vue.js

Awesome Lists containing this project

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;
}