andybest
V2EX  ›  问与答

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

  •  
  •   andybest · Aug 6, 2013 · 5146 views
    This topic created in 4694 days ago, the information mentioned may be changed or developed.
    在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 replies    1970-01-01 08:00:00 +08:00
    BeijingBaby
        1
    BeijingBaby  
       Aug 6, 2013   ❤️ 1
    没有用到 http://getbootstrap.com/javascript 这里的东西就可以不用。
    andybest
        2
    andybest  
    OP
       Aug 6, 2013
    @BeijingBaby 谢谢,也就是我只根据 http://getbootstrap.com/css/http://getbootstrap.com/components/ 里面的例子写页面,就不需要引用 bootstrap.min.js ?
    leiz
        3
    leiz  
       Aug 6, 2013   ❤️ 1
    css是样式文件,负责你的组件看起来是什么样,js负责你的组件动起来是怎么样,只要你的组件没有自身的动作,可以不用.js
    BeijingBaby
        4
    BeijingBaby  
       Aug 6, 2013   ❤️ 1
    @andybest 差不多,但页面有写明 Plugin dependency

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

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

    顶部的Dropdown按钮无效,哈哈,开发团队也需要来看看楼主的这个问题。
    LokiSharp
        7
    LokiSharp  
       Aug 7, 2013 via iPhone
    @halo 这个本来就没东西吧? 下面的链接还是404ne q
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   3052 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 50ms · UTC 13:38 · PVG 21:38 · LAX 06:38 · JFK 09:38
    ♥ Do have faith in what you're doing.