简体   繁体   English

如何使用多个 b-form-radio-group 避免它们之间的视觉干扰?

[英]How can I use multiple b-form-radio-group avoiding visual interference among them?

I'm new using Vue and specifically Bootstrap Vue and I'm trying to build a form with multiple radio groups.我是使用 Vue 尤其是 Bootstrap Vue 的新手,我正在尝试构建一个包含多个无线电组的表单。

My problem is that when I change the value in one of them the others don't change their values (this was checked with Vue DevTools) but visually it looks like none of the values are selected我的问题是,当我更改其中一个值时,其他值不会更改它们的值(已使用 Vue DevTools 进行了检查),但从视觉上看,似乎没有选择任何值

I don't know what is wrong with my approach我不知道我的方法有什么问题

I post here a simplified version of the code looking for some help, thanks in advance:我在这里发布了代码的简化版本以寻求帮助,在此先感谢:

<template>
  <div>

    <b-form-group label="Radio group 1" v-slot="{ ariaDescribedby }">
      <b-form-radio-group
        id="radio-group-1"
        v-model="selected1"
        :options="options1"
        :aria-describedby="ariaDescribedby"
        name="radio-options"
      ></b-form-radio-group>

    </b-form-group>
      <b-form-group label="Radio Group 2" v-slot="{ ariaDescribedby }">
        <b-form-radio-group
          id="radio-group-2"
          v-model="selected2"
          :options="options2"
          :aria-describedby="ariaDescribedby"
          name="radio-options"
        ></b-form-radio-group>
      </b-form-group>

  </div>
</template>

<script>
  export default {
    data() {
      return {
        selected1: 'first',
        options1: [
          { text: 'First', value: 'first' },
          { text: 'Second', value: 'second' },
        ],
        selected2: 'one',
        options2: [
          { text: 'One', value: 'one' },
          { text: 'Two', value: 'two' },
       ]
      }
    }
  }
</script>

Since both <b-form-radio-group> elements have the same name, "radio-options", visually they are treated like one group.由于两个<b-form-radio-group>元素具有相同的名称“radio-options”,因此在视觉上它们被视为一组。 The different v-model would still function correctly but this isn't what you want visually.不同的v-model仍然会正确地 function 但这不是你想要的视觉效果。 Give the second group a different name:给第二组一个不同的名字:

<b-form-radio-group
  id="radio-group-2"
  v-model="selected2"
  :options="options2"
  :aria-describedby="ariaDescribedby"
  name="radio-options2"   
></b-form-radio-group>

Here I changed it to radio-options2 .在这里,我将其更改为radio-options2

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 通过 arguments *和*在 bootstrap vue 中使用 @change 的点击值<b-form-radio-group>元素</b-form-radio-group> - Pass arguments *and* clicked value with @change in bootstrap vue's <b-form-radio-group> element 如何在HTML表单中创建两组单选按钮,并且当A组中的更改将在B组中更改时? - How can I create two groups of radio buttons in a HTML form and when change in A Group will change in B Group? 在单选按钮组中,如何使其中两个启用一个文本框,而其中一个禁用/只读该文本框 - In radio button group, how can I make 2 of them enable a textbox and one of them disable/readonly the textbox 如何从单选按钮获取多个值,然后将它们分配给单个变量并显示在页面上? - How can I get multiple values from a radio button and then assign them into single variables and display them on a page? 如何统一从多组单选按钮和多组复选框中获取的文本? - How can I unify text that take from multiple group radio button and multiple group checkbox? 如何为多个单选按钮使用一个事件处理程序? - How can I use one event handler for multiple radio buttons? 如何统一来自多个组单选按钮的文本? - How can I unify text that take from multiple group radio button? 如何将不同的画布绘图视为一个,如何追踪其中的顺序? - How can I treat different canvas-drawing as one , and how can I trace the sequence among them? 我如何在 md-table 中使用 md-radio-group 和 ng-repeat? - How can i use md-radio-group with ng-repeat inside md-table? 如何检查我的单选按钮是否在一个div中被选中? - How can I check whether my radio button is checked within ONE div among many others?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM