表单元素radio value无法绑定 #66
Closed
Comments
建议直接用 radio-group : <template>
<div>
<radio-group class="radio-group" @change="radioChange">
<label class="radio" v-for="(item, index) in items" :key="item.name">
<radio :value="item.name" :checked="item.checked"/> {{item.value}}
</label>
</radio-group>
</div>
</template>
<script>
export default {
data () {
return {
items: [
{name: 'USA', value: '美国'},
{name: 'CHN', value: '中国', checked: 'true'},
{name: 'BRA', value: '巴西'},
{name: 'JPN', value: '日本'},
{name: 'ENG', value: '英国'},
{name: 'TUR', value: '法国'}
]
}
},
methods: {
radioChange (e) {
console.log('radio发生change事件,携带value值为:', e.target.value)
}
}
}
</script> 参见微信文档: https://mp.weixin.qq.com/debug/wxadoc/dev/component/radio.html |
Closed
遇到相同bug, 改写成: 估计原因:mpvue认为原生单标签组件radio没有闭合,认为同组中的所有radio都是同一个标签,所以会造成点击后面的label,但是总是第一个radio被勾选的bug. |
解决方法无效呀 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
在使用input type=radio时候,编译之后,radio标签中的value值一直为空,不知道如何绑定
The text was updated successfully, but these errors were encountered: