【问题标题】:How to integrate an external javascript file into PugJS?如何将外部 javascript 文件集成到 PugJS 中?
【发布时间】:2018-04-08 04:19:18
【问题描述】:

我正在尝试使用 Node.js 和 Express 和 PugJS 作为模板引擎来制作 Web 应用程序。

我的问题:我正在使用谷歌地图 API,我想将我所有的谷歌地图 API 函数编码到一个单独的 javascript 文件中。我不知道如何在 pugJS 页面中呈现这个外部 javascript 文件并从外部 js 文件调用函数。

【问题讨论】:

    标签: javascript node.js pugjs


    【解决方案1】:

    这很容易;您应该使用标签script,如下所示;

    // jquery as an example, include your own script
    script(src='/assets/plugins/jquery/jquery.min.js')
    script.
        // call your functions here
        $(function () {
            alert('hey')
        })
    

    【讨论】:

      猜你喜欢
      • 2019-03-20
      • 1970-01-01
      • 2017-11-21
      • 2014-03-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-06-24
      相关资源
      最近更新 更多