Jade 中的 Sweetalert2

Sweetalert2 in Jade

我是 javascript/jade 的新手。我正在尝试使用 jade 模板文件中的 sweetalert2 创建一个简单示例。当我 运行 以下内容时,我收到 'Help Me' 警报,但是当我到达 swal 行时,我收到:

ReferenceError: swal 未定义

html  
  head
    title= title
    style.
      body {
        font-family: verdanna;
        font-size: 19px;
        background: #aaaaaa;
      }
    link(type='text/css' rel='stylesheet' href='file:///home/dave/css/sweetalert2.css')
  body
    script(src='file:///home/dave/js/sweetalert2.min.js')
    script.
      var func=function() {
        alert('Help me');
        swal('swal help');
    block content
      h2 Hello
      button(onclick='func()') Alert
  footer
    .row
      .col-xs-12
        small © Neo Inc 2017

应该注意的是,我 运行 这是从一个基于 express/node.js 的玩具应用程序中获取的。我已经通过复制代码中的位置并将它们插入浏览器的另一个选项卡来验证 sweetalert2.css 和 sweetalert2.min.js 文件是否存在。任何 suggestions/help 将不胜感激。

问题是您不能在使用 HTTP 协议(​​source). You need to specify a relative path,例如 src='../myPage.js'。该路径应该相对于 HTML/Pug 文件所在的目录。