没有npm的Sweet Alert 2

时间:2019-03-04 01:23:00

标签: sweetalert2

我的应用不是npm,我需要使用Sweet Alert 2。

我在https://sweetalert2.github.io网站上寻找信息,但没有成功。

没有npm,有没有办法使用Sweet Alert 2?

问候,费利佩。

2 个答案:

答案 0 :(得分:0)

我找到了答案,只需在导入所有JavaScript之前使用以下标签,即可避免错误:

<script src="https://cdn.jsdelivr.net/npm/sweetalert2@8"></script>

答案 1 :(得分:0)

只需在视图中添加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>
相关问题