【问题标题】:Yeoman, angular & bootstrap - how to include new bootstrap javascript components with Bower?Yeoman, angular & bootstrap - 如何在 Bower 中包含新的 bootstrap javascript 组件?
【发布时间】:2014-10-24 14:41:44
【问题描述】:

tooltip.js 默认情况下不包含在 Bootstrap 中,但我想将其添加到使用 Bower 的 Yoeman 脚手架应用程序中。我尝试将其添加到 bower.json 数组中的 main

"main": [
"less/bootstrap.less",
"dist/css/bootstrap.css",
"dist/js/bootstrap.js",
"js/tooltip.js",
"dist/fonts/glyphicons-halflings-regular.eot",
"dist/fonts/glyphicons-halflings-regular.svg",
"dist/fonts/glyphicons-halflings-regular.ttf",
"dist/fonts/glyphicons-halflings-regular.woff"
],

但这不会自动包含在<!-- bower:js -->index.html 内的脚本列表中。如何更新此依赖项列表并让 bower 重建此列表?有没有办法在不手动将要求添加到bower.json 的情况下做到这一点?

【问题讨论】:

  • 您是否在编辑完 bower.json 后重新运行 bower install?
  • 凉亭安装什么?我最初没有通过 bower 安装引导程序,因为它是 yeoman 中角种子的一部分
  • 向 bower.json 添加内容不会将其包含在项目中,它只是文件中的一行。如果您已编辑 bower.json 以包含新内容,请在命令行中导航到包含 bower.json 的目录并运行“bower install”。这将检测要添加的新组件,下载并添加文件并包含在您的 index.html 中
  • 这不会更新任何内容。需要明确的是,我已将"js/tooltip.js" 添加到bower_components/bootstrap 内的bower.json 中,然后从与bower.json 文件相同的文件夹中运行bower install(和bower install --save)。没发生什么事!感谢您的帮助。
  • 我不建议编辑嵌套在 bootstrap 文件夹中的 bower.json。这是引导项目的依赖项列表。您希望在项目中添加一些内容,因此您应该将其添加到项目根目录中 bower.json 的依赖项中,然后运行 ​​bower install

标签: angularjs twitter-bootstrap yeoman bower


【解决方案1】:

如果有人发现此问题,解决方法是在应用程序的主 bower.json 文件中添加到 tooltip.js 文件的相对路径,如下所示:

"dependencies": {
    ...
    "tooltip": "./bower_components/bootstrap/js/tooltip.js"
},

使用bower install --save 将依赖项安装到bower,然后通过调用grunt wiredep 在index.html 中重建bower 包含的文件。

【讨论】:

    猜你喜欢
    • 2023-03-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-06-10
    • 2015-09-15
    • 2015-05-25
    • 2019-11-18
    • 2013-08-27
    相关资源
    最近更新 更多