我的一个项目中有以下目录结构:
/web
/bower_components
/bootstrap
/jquery
/typeahead.js
/views
/index.jade
我尝试通过以下方式使用 index.jade
文件中的这些组件:
link(src='../bower_components/bootstrap/dist/css/bootstrap.min.css', rel='stylesheet')
script(src='../bower_components/jquery/dist/jquery.min.js')
script(src='../bower_components/typeahead.js/dist/typeahead.bundle.min.js')
但它不起作用(此页面上没有 bootstrap
相关样式,并且 jQuery 代码不起作用)。
我应该以不同的方式引用这些组件吗?
我应该将 bower_components
目录放在另一个文件夹中吗?
最佳答案
您可能需要将文件路径更改为相对于您将 jade 文件编译到的位置。
例如,如果你像这样渲染 Jade :
/web
/index.html
源路径是
link(src='bower_components/bootstrap/dist/css/bootstrap.min.css', rel='stylesheet')
script(src='bower_components/jquery/dist/jquery.min.js')
script(src='bower_components/typeahead.js/dist/typeahead.bundle.min.js')
关于javascript - 在上面的目录中找不到bower_components,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33764892/