代码之家  ›  专栏  ›  技术社区  ›  SoaAlex

引导Vue更改活动按钮颜色

  •  0
  • SoaAlex  · 技术社区  · 4 年前

    我在Vue上使用bootstrap。js。

    我有一个这样的表格复选框组

          <b-form-group label="Select flow" v-slot="{ ariaDescribedby }">
            <b-form-checkbox-group
              v-model="selected"
              :options="options"
              :aria-describedby="ariaDescribedby"
              buttons
              button-variant="primary"
              size="lg"
              name="buttons-2"
            ></b-form-checkbox-group>
          </b-form-group>
    

    我希望选择的按钮被设置为一个特定的颜色(而不是它只是有点暗)。

    我尝试添加下面的代码,但不幸的是,它不起作用

    .active {
      background: rgb(243, 16, 0) !important;
    }
    
    

    完整代码如下:

    <template>
      <div class="Overview">
              <b-form-group label="Select flow" v-slot="{ ariaDescribedby }">
            <b-form-checkbox-group
              v-model="selected"
              :options="options"
              :aria-describedby="ariaDescribedby"
              buttons
              button-variant="primary"
              size="lg"
              name="buttons-2"
            ></b-form-checkbox-group>
          </b-form-group>
        </div>
      </div>
    </template>
    
    <script>
    export default {
      name: "Control",
      data() {
        return {
          selected: "F1_Water",
          options: [
            { value: "F1_Water", text: "Water" },
            { value: "F1_Clean", text: "Cleaning solution" },
            { value: "F1_None", text: "None" }
          ]
        };
      }
    };
    </script>
    
    <style>
    .active {
      background: rgb(243, 16, 0) !important;
    }
    </style>
    

    Button group

    1 回复  |  直到 4 年前
        1
  •  3
  •   sebasaenz    4 年前

    你错过了比赛 <style> 开始后的标签 </script> 结束语。

    记住你不应该包括 scoped 因为css样式的目标是一个不同的组件( b-form-checkbox-group 组件),所以

    <style>
      .active {
        background: rgb(243, 16, 0) !important;
      }
    </style>
    

    这是手术的文件 scoped CSS Vue中的功能。js。