【发布时间】:2020-08-31 08:47:30
【问题描述】:
我正在尝试在 NodeJS 中渲染 PUG 页面,jQuery 的问题。
script(language='javascript', src='js/bootstrap.min.js') //works fine
script(src='https://code.jquery.com/jquery-3.5.1.slim.min.js') //**Not working**
script(src='javascripts/jquery.js') //javascripts folder in "public" - **not working.**
引导程序的相同(工作)逻辑:
app.use(express.static(__dirname + '/node_modules/bootstrap/dist'));
//not working for jquery:
app.use(express.static(__dirname + '/node_modules/jquery/dist'));
script(src='/jquery.js') //**Not working**
jquery 是作为一个包与 npm 一起安装的。 如何将 Jquery 包含在哈巴狗中?
【问题讨论】:
-
你的路对吗?
-
我已经尝试了所有路径的变体。我想这是不对的。但我不知道该尝试什么。
-
您的浏览器控制台有错误吗?
-
有一个错误,比如在引导之前放置 jQuery,我做到了。浏览器错误消失。但看起来仍然没有加载 jQuery。我认为这是因为路径。我检查了所有可能的教程,但它从未奏效。
-
您是否要同时加载两个 jquery?一位来自
code.jquery.com,一位来自本地?如果是,那么它可能不起作用,只使用一个。
标签: jquery node.js twitter-bootstrap