I′m trying to create a form. This form have a package.json with vue, axios and sweetalert.
"dependencies": {
"axios": "^0.19.0",
"vue": "^2.6.10",
"vue-sweetalert2": "^2.1.1"
}
The JS is
<script>
import Vue from 'vue';
import VueSweetalert2 from 'vue-sweetalert2';
import VueAxios from 'vue-axios';
import axios from 'axios';
import 'sweetalert2/dist/sweetalert2.min.css';
Vue.use(VueSweetalert2, VueAxios, axios);
var app = new Vue({
el: '#app',
methods: {
guardar: function () {
axios
.get('ENDPONT')
.then(response => {
console.log(response);
Vue.swal('Hello Vue world!!!');
})
.catch(function (error) {
console.log(error);
Vue.swal('Hello Vue world!!!');
});
}
}
});
</script>
The error is simple: Return 'Cannot use import statement outside a module'. I suppose that import is wrong, but im new in Vue and don't know what is the right way.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…