SweetAlert的图像没有出现

时间:2017-04-11 21:49:25

标签: javascript jquery sweetalert

这是我的第一个问题。我希望能够清楚。 所以,我使用SweetAlert来加载带图像的信息,但图像没有出现,我不知道为什么......

window.onbeforeunload = function() {
  swal({
    title: 'Sweet!',
    text: 'Modal with a custom image.',
    imageUrl: 'https://unsplash.it/400/200',
    imageWidth: 400,
    imageHeight: 200,
    animation: false
  })
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://cdn.rawgit.com/t4t5/sweetalert/32bd141c/dist/sweetalert.min.js"></script>
<link href="https://cdn.rawgit.com/t4t5/sweetalert/32bd141c/dist/sweetalert.css" rel="stylesheet" />

<a href="https://www.google.com/">Visit google</a>

我只有图像的框架(如图中所示): enter image description here

请帮帮我

1 个答案:

答案 0 :(得分:0)

$(document).ready(function(){
    swal({
      title: "Sweet!",
      text: "Modal with a custom image.",
      imageUrl: "https://unsplash.it/400/200"
    });
});
<link href="https://cdn.rawgit.com/t4t5/sweetalert/32bd141c/dist/sweetalert.css" rel="stylesheet"/>
<script src="https://cdn.rawgit.com/t4t5/sweetalert/32bd141c/dist/sweetalert.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>

  • 检查是否在swal检查运行之前加载jQuery
  • onbeforeunload事件通过添加提醒('Working ...');
相关问题