@unisharp/vue-component-notification
Version:
Vue Bootstrap Nofifications
68 lines (52 loc) • 1.61 kB
Markdown
# Notification component for vue/nuxt projects
[](https://www.npmjs.com/package/@unisharp/vue-component-notification)
[](https://www.npmjs.com/package/@unisharp/vue-component-notification)
[](https://vuejs.org/)
Vue Bootstrap Notifications
### Installation
```bash
$ yarn add @unisharp/vue-component-notification
```
### Nuxt Setup
`plugins/notification.js`
```javascript
import Vue from 'vue'
import Notifications from '@unisharp/vue-component-notification'
Vue.use(Notifications)
export default ({ store }, inject) => {
// Inject `notify` key
// -> `app.$notify`
// -> `this.$notify` in Vue components
// -> `this.$notify` in store actions/mutations
// This way we can use it in middleware and pages `asyncData` & `fetch`
inject('notify', new Notifications(Vue))
}
```
`nuxt.config.js`
```javascript
...
plugins: ['~/plugins/notification'],
...
```
`layouts/default.vue`
```javascript
<template lang="pug">
div
notifications
nuxt
</template>
```
### Usage
The show method accetps an object.
```javascript
this.$notify.show({message: 'Hello world', type: 'default'})
```
There are 6 helper functions who will accet just a string.
```javascript
this.$notify.primary('Hello world')
this.$notify.default('Hello world')
this.$notify.success('Hello world')
this.$notify.info('Hello world')
this.$notify.warning('Hello world')
this.$notify.danger('Hello world')
```