RadioCell.vue
1.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<!-- components navbar-->
<template>
<van-cell :title="title || data.name" class="radio" :class="clazz" :required="isRequire">
<template>
<van-radio-group v-model="comValue" @change="handleChange" direction="horizontal">
<van-radio :name="item.value" v-for="item in data.value" :key="item.name">{{ item.name }}</van-radio>
</van-radio-group>
</template>
</van-cell>
</template>
<script>
export default {
name: 'RadioCell',
props: ['title', 'data', 'value', 'clazz', 'isRequire'],
computed: {
comValue: {
get() {
if (this.value === null && this.isRequire) {
this.$emit('update:value', this.data.value[0].value)
return this.data.value[0].value
}
return this.value
},
set(val) {
this.$emit('update:value', val)
}
}
},
data() {
return {}
},
methods: {
handleChange(value) {
this.$emit('change', value)
}
}
}
</script>
<style lang="scss" scoped>
@include cellradio();
@include recell(0);
</style>