我正在尝试包含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')));
如果有人能帮我一把,那就太好了。谢谢!
当标记中有文本块时,只需在脚本声明后添加一个.
点即可。
script.
$(document).ready(function(){
$("button").click(function(){
$("p").hide();
});
});
这里的哈巴狗文档很好地解释了它。