![npm](https://img.shields.io/npm/dy/v-dialogs.svg)
A simple and clean instructional dialog plugin for Vue2, dialog type including Modal, Alert, Mask and Toast
Examples and Documentation
Explorer on
The jQuery version: bDialog
The Dialog Icon
The icons in alert dialog used are made by Elegant Themes
The control icon, toast icon used are come from IconFont
Installation
npm i -S v-dialogs
Include plugin in your project
import Vue from 'vue'
import Dialogs from 'v-dialogs'
Vue.use(Dialogs, {
})
Usage
Alert
this.$dlg.alert(message)
this.$dlg.alert(message, callback)
this.$dlg.alert(message, options)
this.$dlg.alert(message, callback, options)
import { DialogAlert } from 'v-dialogs'
DialogAlert(message, [callback], [option])
Modal
import Profile from './Profile.vue'
this.$dlg.modal(Profile, {
width: 400,
height: 300,
title: 'User Profile',
params: {
userId: 1,
userName: 'Terry Zeng'
},
callback: data => {
this.$dlg.alert(`Received message: ${data}`)
}
})
import { DialogModal } from 'v-dialogs'
DialogModal(page, [options])
Toast
this.$dlg.toast(message)
this.$dlg.toast(message, callback)
this.$dlg.toast(message, options)
this.$dlg.toast(message, callback, options)
import { DialogToast } from 'v-dialogs'
DialogToast(message, [callback], [option])
Mask
this.$dlg.mask()
this.$dlg.mask('Data loading, please hold on a moment...')
import { DialogMask } from 'v-dialogs'
DialogMask([message], [callback])
DialogHelper
close
import { DialogMask, DialogHelper } from 'v-dialogs'
const key = DialogMask()
job().then(() => {
DialogHelper.close(key)
})
closeAll
import { DialogHelper } from 'v-dialogs'
fetchData()
.then(() => {
...
})
.catch(error => {
if (error.isLoginTimeout) {
DialogHelper.closeAll()
router.push({ path: '/login' })
}
})