V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX 提问指南
andybest
V2EX  ›  问与答

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

  •  
  •   andybest · 2013-08-06 22:26:44 +08:00 · 4567 次点击
    这是一个创建于 3921 天前的主题,其中的信息可能已经有所发展或是发生改变。
    在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?
    7 条回复    1970-01-01 08:00:00 +08:00
    BeijingBaby
        1
    BeijingBaby  
       2013-08-06 22:28:31 +08:00   ❤️ 1
    没有用到 http://getbootstrap.com/javascript 这里的东西就可以不用。
    andybest
        2
    andybest  
    OP
       2013-08-06 22:35:49 +08:00
    @BeijingBaby 谢谢,也就是我只根据 http://getbootstrap.com/css/http://getbootstrap.com/components/ 里面的例子写页面,就不需要引用 bootstrap.min.js ?
    leiz
        3
    leiz  
       2013-08-06 22:37:04 +08:00   ❤️ 1
    css是样式文件,负责你的组件看起来是什么样,js负责你的组件动起来是怎么样,只要你的组件没有自身的动作,可以不用.js
    BeijingBaby
        4
    BeijingBaby  
       2013-08-06 22:45:37 +08:00   ❤️ 1
    @andybest 差不多,但页面有写明 Plugin dependency

    比如:Button dropdown menus 这个组件 就写有 Button dropdowns require the dropdown plugin to be included in your version of Bootstrap.
    P233
        5
    P233  
       2013-08-06 22:50:04 +08:00
    如果 HTML 用不到 data-* 基本上就不需要 js 库吧
    halo
        6
    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
        7
    LokiSharp  
       2013-08-07 03:19:08 +08:00 via iPhone
    @halo 这个本来就没东西吧? 下面的链接还是404ne q
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   1846 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 28ms · UTC 00:58 · PVG 08:58 · LAX 17:58 · JFK 20:58
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.