-
Notifications
You must be signed in to change notification settings - Fork 351
/
Copy pathBaseRadio.vue
executable file
·63 lines (63 loc) · 1.22 KB
/
BaseRadio.vue
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
58
59
60
61
62
63
<template>
<div class="form-check form-check-radio" :class="[inlineClass, {disabled: disabled}]">
<label :for="cbId" class="form-check-label">
<input :id="cbId"
class="form-check-input"
type="radio"
:disabled="disabled"
:value="name"
v-model="model" />
<slot></slot>
<span class="form-check-sign"></span>
</label>
</div>
</template>
<script>
export default {
name: "base-radio",
props: {
name: {
type: [String, Number],
description: "Radio label"
},
disabled: {
type: Boolean,
description: "Whether radio is disabled"
},
value: {
type: [String, Boolean],
description: "Radio value"
},
inline: {
type: Boolean,
description: "Whether radio is inline"
}
},
data() {
return {
cbId: ""
};
},
computed: {
model: {
get() {
return this.value;
},
set(value) {
this.$emit("input", value);
}
},
inlineClass() {
if (this.inline) {
return `form-check-inline`;
}
return "";
}
},
created() {
this.cbId = Math.random()
.toString(16)
.slice(2);
}
};
</script>