gpt4 book ai didi

javascript - Sweetalert 对话框不会显示

转载 作者:行者123 更新时间:2023-11-28 06:23:32 25 4
gpt4 key购买 nike

window.alert = function (text) {
swal({
title: "Computer says:",
text: text,
timer: 3000,
animation: "slide-from-top"
});
return true;
};

function run(input) {
if (input[0] == "alert") {
ta = input.slice(1, input.length);
tap = ta.join(" ");
alert(tap);
}
}

当我调用 run(["alert", "hello"]); in the javascript console ,它工作正常。但是当我 type in alert hello, in my console ,对话框会短暂闪烁并消失。这里发生了什么,我该如何阻止它?谢谢!

最佳答案

它工作正常我什至在控制台中也看不出有什么问题:

  <!DOCTYPE html>
<html>
<head>
<title></title>
<link rel="stylesheet" type="text/css" href="sweetalert.css">
</head>
<body>
<script src="sweetalert.min.js"></script>
<script type="text/javascript">
window.alert = function (text) {
swal({
title: "Computer says:",
text: text,
timer: 3000,
animation: "slide-from-top"
});
return true;
};
function run(input) {
if (input[0] == "alert") {
ta = input.slice(1, input.length);
tap = ta.join(" ");
alert(tap);
}
}
run(["alert", "hello"]);
</script>
</body>
</html>

关于javascript - Sweetalert 对话框不会显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35415338/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com