首页 文章

为什么Sweet Alert在这种情况下仅适用于 生产环境 ?

提问于
浏览
-2

在制作中,我可以使用Sweet Alert,但是当我放置网站时,我收到此错误:

未捕获的ReferenceError:未定义swal

我跑了 npm install sweetalert 并将这两行添加到index.html的头部:

<SCRIPT SRC = “node_modules / sweetalert / DIST / sweetalert.min.js”> <链接的rel = “样式表的” href = “node_modules / sweetalert / DIST / sweetalert.css”>

他们应该在哪里?他们应该在其他地方/无处吗?

页面加载后,Chrome的控制台会显示以下三个错误:

GET https://wfolly.firebaseapp.com/node_modules/sweetalert/dist/sweetalert.css wfolly.firebaseapp.com/:24 GET https://wfolly.firebaseapp.com/node_modules/sweetalert/dist/sweetalert.min . js wfolly.firebaseapp.com/:25 GET https://wfolly.firebaseapp.com/node_modules/sweetalert/dist/sweetalert.css

我已经尝试使用和不使用node_modules / sweetalert目录来部署网站 .

我是新手 . 可能存在一个基本错误 .

想法欢迎 .

1 回答

  • 0

    如果你保持

    <link rel =“stylesheet”href =“node_modules / sweetalert / dist / sweetalert.css”>

    在头部保留我对CSS所做的更改,但用脚本替换

    <script src =“https://cdnjs.cloudflare.com/ajax/libs/sweetalert/1.1.3/sweetalert.min.js”> </ script>

    有用!

    让我们花一点时间来感谢那些因为耐心和慷慨而对这个问题进行投票的人们 .

相关问题