0
I’m trying to use swal2 in Vue, but with this import I’m getting the error
Uncaught Typeerror: Failed to resolve module specifier "Vue-sweetalert2.js". Relative References must start with either "/", ". /", or "../".
I’m importing by following the footsteps of this link: https://www.npmjs.com/package/vue-sweetalert2
import Vuesweetalert2 from 'Vue-sweetalert2.js'
Vue.use(Vuesweetalert2);
I’ve tried using . /Vue-sweetalert2.js and even specify the path, but it doesn’t solve. When I try to specify the path I get the error (Not Found).
import VueSweetalert2 from 'vue-sweetalert2.js'
Vue.use(VueSweetalert2)
new Vue({
el: '#signin-form',
components: {
},
data: {
email: "",
password: ""
},
mounted() {
},
methods: {
showAlert(){
this.$swal('Olá, você logou com sucesso!');
},
processForm(){
axios({
method: "POST",
"url": "http://192.168.0.138:8000/api/loginCandidate",
data: {"email": this.email, "password": this.password},
}).then(result => {
if(result.data.result){
var candidate = result.data.candidate;
var token = Object.values(result.data.token);
var keys = Object.keys(candidate);
localStorage.setItem("token", token);
for(var i = 0; i {
console.error(error);
});
},
}
})
Additional import or component required?
Add in main.js
import VueSweetalert2 from 'vue-sweetalert2.js'
Vue.use(VueSweetalert2)
– Marconi
There in the documentation in the first part of the use, already has showing this information!
– Marconi
Already set..... import privateProps from'.. /privateProps' import Vue from'.. /Vue' import Vuesweetalert2 from'.. /Vue-sweetalert2' Vue.use(Vuesweetalert2)
– Guilherme Queiróz
Did it work? Your path is right?
– Marconi
The error continues, the path is correct. In this case I am using import inside the _main.js folder of sweetalert2, as it is in the link. I tried to throw the way too.
– Guilherme Queiróz
npm i
tentoou?– Marconi
I tried : .....
– Guilherme Queiróz