html - SweetAlert 问题
问题描述
我一直在尝试在 HTML 中使用 SweetAlert,由于某种原因,它没有将 swal() 识别为函数。它只是把它作为文本放到他的页面上。我对 HTML 非常陌生,因为 Lua 和 Node.js 是我的主要语言。
这是页面上显示的内容。
swal("test", { icon: "warning", });
代码:
<html>
<script src="https://unpkg.com/sweetalert/dist/sweetalert.min.js"></script>
swal("test", {
icon: "warning",
});
</html>
如果在 HTML 方面有更多经验的人能够指出我正确的方向,将不胜感激。
解决方案
JavaScript 在 HTML 文件中时,应包含在<script></script>
标签中。您还需要包含一个head
部分,因此您的 HTML 将如下所示:
<html>
<head>
<script src="https://unpkg.com/sweetalert/dist/sweetalert.min.js"></script>
</head>
<body>
<script>
swal('test', {icon: 'warning'});
</script>
</body>
</html>
推荐阅读
- swift - swift 为什么要使用扩展程序
- java - 使用 java8 流从多级内部列表中检索数据
- python - AttributeError:“系列”对象没有属性“重塑”
- java - Opengl - GLSL - 在一个浮点数中存储 4 个字节并将其发送到着色器
- logstash - 关于传递给zabbix trapper的ELK-Logstash关键字过滤器
- python - 如何在python中制作正则表达式
- wordpress - 许多带有尾随双斜杠的 URL?
- react-native - 推送不在标签 wix v2 中的屏幕
- java - NoClassDefFoundError:Android 应用程序崩溃
- spring - hibernate 在执行时没有运行插入和更新