Vue-Easy-Notify
Introduction
Vue Notify is very minimal and simple to use plugin available for VueJs, It comes with mixin that you can use to easily integrated your server-service notifications with vue-easy-notify.
Demo
Quick Start
NPM
Install the package:
npm install vue-easy-notify
Register the plugin:
Vue
Use the component:
// you can call like this in your componentthis // and also Vueprototype
Great Now you have this cool vue-easy-notify installed on your project..
Examples
// notify by notification typethis // notify with timeoutthis message: 'Example message.' type: 'success' timeout: 3000 // shorthand methodsthis;this;this;this;
Server Side Usage
Below is the example how you can use vue-easy-notify to handle laravel server side flash message and errors.
Install laracasts/flash composer package.
composer require laracasts/flash
// ExampleController// ... //public function index(){ flash()->info('server side flash message.'); return redirect('/home');}// ... //
<!-- layouts/app.blade.php --> <!-- --> {{ session()->forget('flash_notification') }} <!-- --> <!-- --> <!-- -->
add and use this plugin in your project to check laravel notifications
// resources/js/mixins/notifications.js { this; } methods: { if !flash_notification return; flash_notification }
// resources/js/app.js ; // this mixin will automatically check server side notfications.Vue el: '#app' mixins: NotifyMixin { this }
API
Options
below are the options you can pass to notify function.
Option | Type's | Default | Description |
---|---|---|---|
message | String | '' | Notification message content |
type | String | 'info' | Notification level ['info', 'success', 'warning', 'error'] |
size | String | 'sm' | Notification size ['sm', 'lg'] |
timeout | Number | 5000 | Display time of the notification in millisecond |
showClose | Boolean | true | Show close icon on notification [true, flase] |