E021 - alex1221/bootlint-customization GitHub Wiki

E021

在使用button.js插件时,btn-group 元素中的 checked 属性外面没有添加 .active 类(或者使用 .active 类,但是里面的元素没有 checked 属性)

当使用Bootstrap的 button.js jQuery组件的单选按钮或多选按钮组样式时, 您必须确保 <label> 在其DOM被加载时预选或预选的选项添加了 .active 类。只有这样,Bootstrap 才会正确地渲染以响应用户交互。


错误的:

<div class="btn-group" data-toggle="buttons">
  <label class="btn btn-primary">
    <input type="checkbox" checked /> Option 1 (pre-checked)
  </label>
  <label class="btn btn-primary active">
    <input type="checkbox" /> Option 2 (not pre-checked)
  </label>
</div>

正确的:

<div class="btn-group" data-toggle="buttons">
  <label class="btn btn-primary active">
    <input type="checkbox" checked /> Option 1 (pre-checked)
  </label>
  <label class="btn btn-primary">
    <input type="checkbox" /> Option 2 (not pre-checked)
  </label>
</div>

错误的:

<div class="btn-group" data-toggle="buttons">
  <label class="btn btn-primary">
    <input type="radio" name="options" id="option1" checked /> Option 1 (preselected)
  </label>
  <label class="btn btn-primary active">
    <input type="radio" name="options" id="option2" /> Option 2 (not preselected)
  </label>
</div>

正确的:

<div class="btn-group" data-toggle="buttons">
  <label class="btn btn-primary active">
    <input type="radio" name="options" id="option1" checked /> Option 1 (preselected)
  </label>
  <label class="btn btn-primary">
    <input type="radio" name="options" id="option2" /> Option 2 (not preselected)
  </label>
</div>
⚠️ **GitHub.com Fallback** ⚠️