0👍
There’s actually a discussion on this very question in an issue on the vue-sweetalert2 repo.
Some people prefer using a Vue wrapper around libraries in order to make using them more ‘vue-like’.
Sometimes such wrappers add custom components to allow using them in a declarative manner, which can make them worth considering, but you always have to consider that you’re adding an additional dependency that may not be updated as frequently as the library it’s wrapping.
In this particular case, you’re really not gaining anything from using the wrapper, and (as mentioned in the issue comments) you’d be better off making the dependency on sweetalert more explicit with an import statement:
<template>
<button v-on:click="showAlert">Hello world</button>
</template>
<script>
import swal from 'sweetalert2'
export default {
data() {
return {};
},
methods: {
showAlert(){
// Use sweetalret2
swal('Hello Vue world!!!');
}
}
}
</script>
- [Vuejs]-Set-Cookie not accessible through axios or fetch
- [Vuejs]-Is it possible to add HTML elements in which store some data in Vue?
Source:stackexchange.com