npm install -S vue-sweetalert2
// Main Js
import Vue from 'vue'
import VueSweetalert2 from 'vue-sweetalert2';
import App from './App.vue';
Vue.use(VueSweetalert2);
new Vue({
el: '#app',
render: h => h(App)
});
// app.vue
<template>
<!-- button used to trigger event -->
<button v-on:click="alertDisplay">Click me</button>
</template>
<script>
export default {
data() {
return {
text: ''
}
},
methods: {
alertDisplay() {
// $swal function calls SweetAlert into the application with the specified configuration.
this.$swal('Heading', 'this is a Heading', 'OK');
}
}
}
<script>