uniapp中单选按钮的实现
程序员文章站
2022-01-15 10:57:49
...
<template>
<view>
<radio-group @change="chan">
<label v-for="item in radioGroup" :key="item">
<radio :value="item" :checked="item==activeRadio" />{{item}}
</label>
</radio-group>
</view>
</template>
<script>
export default{
data(){
return{
activeRadio:'', //存的是选中的value值
radioGroup:['苹果','香蕉','梨','西红柿','西瓜']
}
},
methods:{
chan(e){
this.activeRadio = e.detail.value;
console.log(this.activeRadio);
}
}
}
</script>