相关疑难解决方法(0)

vuejs单选按钮组件

我试图让这个自定义单选按钮组件在vuejs中工作.如何使用父组件中的值检查单选按钮.我知道你使用v-model并将其设置为其中一个输入值中的相同值,但它似乎无法使其工作.

零件:

export default Vue.component('radioButton', {
  template,
  props: ['name', 'label', 'id', 'value']
})
Run Code Online (Sandbox Code Playgroud)

组件模板:

<label class="radio" :for="id">
  <input type="radio" :id="id" class="radio-button" :value="value" :name="name">
   <span class="radio-circle">
  </span>
  <span class="radio-circle__inner">
  </span>
  <span class="radio-button__label">{{ label }}</span>
</label>
Run Code Online (Sandbox Code Playgroud)

HTML:

<radio-button name="options" id="option-1" label="1" :value="selectedValue" />
<radio-button name="options" id="option-2" label="2" :value="selectedValue" />
Run Code Online (Sandbox Code Playgroud)

radio-button vue.js vue-component

7
推荐指数
1
解决办法
2万
查看次数

标签 统计

radio-button ×1

vue-component ×1

vue.js ×1