代码之家  ›  专栏  ›  技术社区  ›  fuzzybabybunny

如何正确地将CDN添加到Meteor 1.5项目?

  •  1
  • fuzzybabybunny  · 技术社区  · 7 年前

    /client/main.html

    <head>
      <title>Meteor ESP8266</title>
      <link href="https://gitcdn.github.io/bootstrap-toggle/2.2.2/css/bootstrap-toggle.min.css" rel="stylesheet">
      <script src="https://gitcdn.github.io/bootstrap-toggle/2.2.2/js/bootstrap-toggle.min.js"></script>
    </head>
    
    <body>
      <div id="app"></div>
    </body>
    

    的CDN bootstrap-toggle.min.js 给了我 Uncaught ReferenceError: jQuery is not defined

    1 回复  |  直到 7 年前
        1
  •  3
  •   Styx    7 年前

    只需添加 defer <script> 标签:

    <script defer src="..."></script>
    

    这将导致浏览器在解析文档(和加载其他脚本)后执行脚本。

    MDN documentation .