我试图让这个自定义单选按钮组件在vuejs中工作。如何使用父组件的值检查单选按钮。我知道你使用v模型并将其设置为一个输入值中的相同值,但它似乎不能使其工作。vuejs单选按钮组件
组件:export default Vue.component('radioButton', { template, props: ['name', 'label', 'id', 'value'] })
组件模板:
<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>
HTML:
<radio-button name="options" id="option-1" label="1" :value="selectedValue" />
<radio-button name="options" id="option-2" label="2" :value="selectedValue" />
你可以发布一个jsfiddle你已经做了什么? – highFlyingDodo