无法在上面的目录中找到bower_components

时间:2015-11-17 18:57:49

标签: javascript html bower

我的一个项目中有以下目录结构:

/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目录放在另一个文件夹中吗?

1 个答案:

答案 0 :(得分:1)

您可能需要将文件路径更改为相对于编译玉文件的位置。

例如,如果你像这样渲染玉石:

/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')