-
Notifications
You must be signed in to change notification settings - Fork 485
/
Copy pathindex.vue
81 lines (72 loc) · 1.92 KB
/
index.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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
<template>
<div class="list list-ios von-checkbox">
<label class="item item-borderless item-icon-left" v-for="(option, i) in options">
<hairline-top v-if="i > 0"></hairline-top>
<input type="checkbox" :name="checkboxName" :id="checkboxName + '-' + i"
v-model="v" :value="i" @click="onClick(i)" hidden>
<span v-text="option"></span>
<i class="icon ion-ios-checkmark"
:class="{
'grey': v.indexOf(i) <= -1,
'assertive': v.indexOf(i) > -1 && theme == 'assertive',
'positive': v.indexOf(i) > -1 && theme == 'positive',
'balanced': v.indexOf(i) > -1 && theme == 'balanced',
'energized': v.indexOf(i) > -1 && theme == 'energized',
'calm': v.indexOf(i) > -1 && theme == 'calm',
'royal': v.indexOf(i) > -1 && theme == 'royal',
'dark': v.indexOf(i) > -1 && theme == 'dark'
}"
>
</i>
<hairline-bottom v-if="i < options.length - 1"></hairline-bottom>
</label>
</div>
</template>
<script>
import HairlineTop from '../list/HairlineTop'
import HairlineBottom from '../list/HairlineBottom'
export default{
components: {
HairlineTop,
HairlineBottom
},
props: {
options: {
type: Array,
required: true
},
value: {
type: [Array, Number],
required: true
},
theme: {
type: String,
default: 'assertive'
}
},
computed: {
v: {
get:function(){
return this.value
},
set:function(){}
}
},
data() {
return {
checkboxName: 'von-checkbox-' + Math.random().toString(36).substring(3, 6)
}
},
methods: {
onClick(i) {
let index = this.v.indexOf(i)
if (index == -1) {
this.v.push(i)
} else {
this.v.splice(index, 1)
}
this.v.sort()
}
}
}
</script>