Bootstrap在什么情况下可以不引用bootstrap.min.js?

2013-08-06 22:26:44 +08:00
 andybest
在Bootstrap的Get start里教我们这么做:
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.0.0-rc1/css/bootstrap.min.css">

<!-- Latest compiled and minified JavaScript -->
<script src="//netdna.bootstrapcdn.com/bootstrap/3.0.0-rc1/js/bootstrap.min.js"></script>

然而实际的情况则是在 http://examples.getbootstrap.com/ 这里面的所有examples全部没有引用bootstrap.min.js而仅仅是一个bootstrap.css

所以我想知道在用Bootstrap时在什么情况下我可以不引用bootstrap.min.js?如何简单的判断出来是否需要bootstrap.min.js?
4580 次点击
所在节点    问与答
7 条回复
BeijingBaby
2013-08-06 22:28:31 +08:00
没有用到 http://getbootstrap.com/javascript 这里的东西就可以不用。
andybest
2013-08-06 22:35:49 +08:00
@BeijingBaby 谢谢,也就是我只根据 http://getbootstrap.com/css/http://getbootstrap.com/components/ 里面的例子写页面,就不需要引用 bootstrap.min.js ?
leiz
2013-08-06 22:37:04 +08:00
css是样式文件,负责你的组件看起来是什么样,js负责你的组件动起来是怎么样,只要你的组件没有自身的动作,可以不用.js
BeijingBaby
2013-08-06 22:45:37 +08:00
@andybest 差不多,但页面有写明 Plugin dependency

比如:Button dropdown menus 这个组件 就写有 Button dropdowns require the dropdown plugin to be included in your version of Bootstrap.
P233
2013-08-06 22:50:04 +08:00
如果 HTML 用不到 data-* 基本上就不需要 js 库吧
halo
2013-08-06 22:59:55 +08:00
听 @BeijingBaby @leiz 这么一说,我发现bootstrap自己也玩陷了,

Demo页面:
http://examples.getbootstrap.com/navbar/index.html
http://examples.getbootstrap.com/sticky-footer-navbar/index.html

顶部的Dropdown按钮无效,哈哈,开发团队也需要来看看楼主的这个问题。
LokiSharp
2013-08-07 03:19:08 +08:00
@halo 这个本来就没东西吧? 下面的链接还是404ne q

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/78229

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX