【发布时间】:2020-10-01 07:38:16
【问题描述】:
我正在尝试包含 jquery 库以公开它的一些功能。我遵循了教程,查看了示例,但我收到了一个奇怪的错误,这清楚地表明我没有正确加载模块。
错误:
10| script(src="https://code.jquery.com/jquery-3.5.1.min.js" integrity="sha256-9/aliU8dGd2tb6OSsuzixeV4y/faTqgFtohetphbbj0=" crossorigin="anonymous")
11| script
> 12| $(document).ready(function(){
------------------------^
13| $("button").click(function(){
14| $("p").hide();
15| });
unexpected text "$(doc"
现在我想我可以简单地导入带有经典脚本标签的脚本,但它不起作用。这是我的基本模板标题。
doctype html
html
head
block head
meta(charset=utf-8)
meta(viewport='viewport' content='width=device-width, initial-scale=1.0')
link(rel='stylesheet', href='/css/style.css')
link(rel='stylesheet', href='/css/testTables.css')
link(rel='stylesheet', href='/css/tableStyles.css')
script(src="https://code.jquery.com/jquery-3.5.1.min.js" integrity="sha256-9/aliU8dGd2tb6OSsuzixeV4y/faTqgFtohetphbbj0=" crossorigin="anonymous")
script
$(document).ready(function(){
$("button").click(function(){
$("p").hide();
});
});
现在澄清一下,它存储在我的项目根目录中的我的视图文件夹中。我正在使用 nodeJS 和 express。我也有 jquery 包作为依赖项。我的项目也从此处定义的根/公共文件夹提供服务。
//all the static assets are being served from public
app.use(express.static(path.join(__dirname,'public')));
如果有人能帮我一把,那就太好了。谢谢!
【问题讨论】:
标签: jquery node.js express pug web-deployment