Vuejs plugin to use sweetalert js lib in a smart way.
- Author: Valerio Barbera - support@gistmetrics.com
- Author Website: www.gistmetrics.com
npm install @aventure-cloud/vuejs-sweetalert-bridge --save
import AlertsPlugin from '@aventure-cloud/vuejs-sweetalert-bridge';
Vue.use(AlertsPlugin);
Inside your vuejs components:
methods: {
save(){
this.$alerts.confirm(() => {
console.log('Action confirmed');
});
}
}
If you need to use a raw swal instance:
this.$alerts.swal();
Main alerts types success, info, error
can be used as notification:
this.$alerts.notify('info', {title: 'More info!'});
Notification is success by default:
this.$alerts.notify();
All plugin element return swal promise to control post execution:
// Alerts
this.$alerts.success().then(() => {
console.log('Post alert execution');
});
// Notification
this.$alerts.notify().then(() => {
console.log('Post notification execution');
});
this.$alerts.confirm((v) => {
console.log(v);
}, {
input: 'textarea',
inputPlaceholder: 'Type your message here'
});