2026-06-09 17:49:15 +08:00
|
|
|
<template>
|
|
|
|
|
<view class="form-radio">
|
2026-06-10 10:15:10 +08:00
|
|
|
<view v-for="(item, index) in options" :key="index" class="radio-item" @click="onSelect(item)">
|
|
|
|
|
<view class="radio-dot" :class="{ active: value === item }"></view>
|
|
|
|
|
<text class="radio-label">{{ item }}</text>
|
2026-06-09 17:49:15 +08:00
|
|
|
</view>
|
|
|
|
|
</view>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script>
|
|
|
|
|
export default {
|
2026-06-10 10:15:10 +08:00
|
|
|
name: 'FormItemRadio',
|
2026-06-09 17:49:15 +08:00
|
|
|
props: {
|
2026-06-10 10:15:10 +08:00
|
|
|
value: { type: [String, Number], default: '' },
|
|
|
|
|
options: { type: Array, default: function () { return []; } }
|
2026-06-09 17:49:15 +08:00
|
|
|
},
|
|
|
|
|
methods: {
|
2026-06-10 10:15:10 +08:00
|
|
|
onSelect: function (val) {
|
|
|
|
|
this.$emit('input', val);
|
2026-06-09 17:49:15 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<style scoped>
|
|
|
|
|
.form-radio {
|
|
|
|
|
display: flex;
|
|
|
|
|
flex-wrap: wrap;
|
|
|
|
|
}
|
2026-06-10 10:15:10 +08:00
|
|
|
|
2026-06-09 17:49:15 +08:00
|
|
|
.radio-item {
|
|
|
|
|
display: flex;
|
|
|
|
|
align-items: center;
|
|
|
|
|
margin-right: 40rpx;
|
|
|
|
|
margin-bottom: 16rpx;
|
|
|
|
|
}
|
2026-06-10 10:15:10 +08:00
|
|
|
|
2026-06-09 17:49:15 +08:00
|
|
|
.radio-dot {
|
|
|
|
|
width: 36rpx;
|
|
|
|
|
height: 36rpx;
|
|
|
|
|
border-radius: 50%;
|
|
|
|
|
border: 2rpx solid #cccccc;
|
|
|
|
|
margin-right: 12rpx;
|
|
|
|
|
position: relative;
|
|
|
|
|
}
|
2026-06-10 10:15:10 +08:00
|
|
|
|
2026-06-09 17:49:15 +08:00
|
|
|
.radio-dot.active {
|
|
|
|
|
border-color: #e8101e;
|
|
|
|
|
background-color: #e8101e;
|
|
|
|
|
}
|
2026-06-10 10:15:10 +08:00
|
|
|
|
2026-06-09 17:49:15 +08:00
|
|
|
.radio-dot.active::after {
|
2026-06-10 10:15:10 +08:00
|
|
|
content: '';
|
2026-06-09 17:49:15 +08:00
|
|
|
position: absolute;
|
|
|
|
|
top: 50%;
|
|
|
|
|
left: 50%;
|
|
|
|
|
transform: translate(-50%, -50%);
|
|
|
|
|
width: 16rpx;
|
|
|
|
|
height: 16rpx;
|
|
|
|
|
border-radius: 50%;
|
|
|
|
|
background-color: #ffffff;
|
|
|
|
|
}
|
2026-06-10 10:15:10 +08:00
|
|
|
|
2026-06-09 17:49:15 +08:00
|
|
|
.radio-label {
|
|
|
|
|
font-size: 28rpx;
|
|
|
|
|
color: #333333;
|
|
|
|
|
}
|
|
|
|
|
</style>
|