在上面的目录中找不到bower_components

Unable to find bower_components in the directory above

本文关键字:bower components 找不到 在上面      更新时间:2023-09-26

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

/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文件的位置。

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

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