我使用laravel 5.6,vue js是2.5,sweetalert2 8.14.0,并且在提交表单时需要提醒:
//app.js
import swal from 'sweetalert2'
window.swal = swal;
const toast = swal.mixin({
toast: true,
position: 'top-end',
showConfirmButton: false,
timer: 3000
});
window.toast = toast;
//在Vue中
createUser()
{
this.$Progress.start();
this.form.post('api/user');
toast({
type: 'success',
title: 'User Created in successfully'
})
this.$Progress.finish();
},
},
答案 0 :(得分:1)
在我看来,您只是打错了SweetAlert。
而不是这样:
toast({
type: 'success',
title: 'User Created in successfully'
})
应该是:
toast.fire({
type: 'success',
title: 'User Created in successfully'
})
或者,如果您想使用toast
作为函数,则可以将其定义为:
window.toast = function (...args) {
return toast.fire(...args);
};