javascript - 在上面的目录中找不到bower_components

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

最佳答案

您可能需要将文件路径更改为相对于您将 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/

相关文章:

javascript - 当里面有另一个div时,如何获取一级div的文本内容?

php - 在 MySQL 和 PHP 中管理图像

javascript - 点击事件不工作 jQuery

html - PayPal 捐赠按钮 - 如何删除 'recurring donation (monthly)' 选项?

jquery - 无法让使用 Bower 安装的文件在 Eclipse 中工作

javascript - global cli npm 包适用于 windows 但不适用于 linux

javascript - Asp.net Bower安装plotly.js不起作用

javascript - 从 React 组件调用外部 Javascript 函数

javascript - 将垂直堆积条转换为水平堆积条 D3.js v4

带有表情符号的主题标签的 Javascript 正则表达式