1

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

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

4

1 回答 1

2

这很容易;您应该使用标签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')
    })
于 2018-04-07T20:19:18.897 回答