radio.vue
1.3 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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
<template>
<div class="radio-control" v-bind:class="layoutClass">
<template v-for="item in list">
<input type="radio" :value="item.value || item" v-model="checked" :id="uuid + $index" :disabled="disabled">
<label class="radio" :for="uuid+ $index">{{item.label || item}}</label>
</template>
</div>
</template>
<!-- :class="{'radioStyle':item.radioStyle}" -->
<script>
module.exports = {
props: {
radioStyle:{
default:false,
type:Boolean
},
list: {
type: Array,
default: function () {
return [{
value: '1',
label: '是'
}, {
value: '0',
label: '否'
}];
}
},
layout: {
type: Array,
default: ''
},
checked: {
twoWay: true
},
disabled: true,
},
computed: {
layoutClass: function () {
var clazz = [];
for (var i = 0, len = this.layout.length; i < len; i++) {
if (this.layout[i] === 'control') {
continue;
}
clazz.push('radio-' + this.layout[i]);
}
return clazz;
}
},
data: function () {
return {
uuid: 'radio_' + Math.random().toString().substr(2).toString(32)
};
}
};
</script>