我的应用程序不是npm,我需要使用Sweet Alert 2。
我在网站https://sweetalert2.github.io上寻找信息,但没有成功。
有没有办法在没有npm的情况下使用Sweet Alert 2?
此致,菲利普。
我找到了答案,只需在所有javascript导入之前使用下面的标记以避免错误:
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@8"></script>
只需在视图中添加cdn链接:
<link href="https://cdnjs.cloudflare.com/ajax/libs/limonte-sweetalert2/7.33.1/sweetalert2.css" rel="stylesheet" type="text/css">
<script src="https://code.jquery.com/jquery-3.4.1.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/limonte-sweetalert2/7.33.1/sweetalert2.js"></script>
Js代码:
<script>
$(document).ready(function(){
Swal.fire({
type: 'success',
title: 'Your work has been done',
showConfirmButton: false,
timer: 1500
})
});
</script>