90 lines
1.3 KiB
Vue
90 lines
1.3 KiB
Vue
![]() |
<template>
|
||
|
<view class="form-item">
|
||
|
<view class="label">性别</view>
|
||
|
<view class="radio-box">
|
||
|
<view @click="change(item)" class="text" :class="item.value == valueDom ? 'active' : ''" v-for="(item,index) in list">{{item.name}}</view>
|
||
|
</view>
|
||
|
</view>
|
||
|
</template>
|
||
|
|
||
|
<script>
|
||
|
export default {
|
||
|
components: {
|
||
|
|
||
|
},
|
||
|
props: {
|
||
|
modelValue: {
|
||
|
type: String,
|
||
|
default: ''
|
||
|
},
|
||
|
},
|
||
|
data() {
|
||
|
return {
|
||
|
list: [
|
||
|
{
|
||
|
name: '男',
|
||
|
value: '0',
|
||
|
},
|
||
|
{
|
||
|
name: '女',
|
||
|
value: '1',
|
||
|
},
|
||
|
],
|
||
|
}
|
||
|
},
|
||
|
created() {
|
||
|
|
||
|
},
|
||
|
computed: {
|
||
|
valueDom() {
|
||
|
return this.modelValue;
|
||
|
},
|
||
|
},
|
||
|
watch: {
|
||
|
|
||
|
},
|
||
|
methods: {
|
||
|
change(e) {
|
||
|
this.$emit('update:modelValue', e.value);
|
||
|
},
|
||
|
}
|
||
|
}
|
||
|
</script>
|
||
|
|
||
|
<style lang="scss" scoped>
|
||
|
.form-item {
|
||
|
background-color: #fff;
|
||
|
display: flex;
|
||
|
align-items: center;
|
||
|
justify-content: space-between;
|
||
|
padding: 15px;
|
||
|
|
||
|
.label {
|
||
|
font-size: 30rpx;
|
||
|
min-width: 200rpx;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
.radio-box {
|
||
|
display: flex;
|
||
|
justify-content: space-between;
|
||
|
align-items: center;
|
||
|
|
||
|
.text {
|
||
|
width: 70rpx;
|
||
|
height: 70rpx;
|
||
|
display: flex;
|
||
|
align-items: center;
|
||
|
justify-content: center;
|
||
|
background-color: #ececec;
|
||
|
color: #949494;
|
||
|
border-radius: 100%;
|
||
|
margin-left: 10px;
|
||
|
}
|
||
|
|
||
|
.active {
|
||
|
color: #fff;
|
||
|
background-color: #949494;
|
||
|
}
|
||
|
}
|
||
|
</style>
|