【发布时间】:2017-03-21 08:30:41
【问题描述】:
我试图让这个自定义单选按钮组件在 vuejs 中工作。如何使用父组件中的值检查单选按钮。我知道您使用 v-model 并在其中一个输入值中将其设置为相同的值,但它似乎无法正常工作。
组件:
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 吗?
标签: radio-button vue.js vue-component