e355dd49
梁灏
add Select Component
|
1
|
<template>
|
e4ebd304
梁灏
update Select com...
|
2
|
<li :class="classes" @click.stop="select" @mouseout.stop="blur" v-show="!hidden"><slot>{{ showLabel }}</slot></li>
|
e355dd49
梁灏
add Select Component
|
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
</template>
<script>
const prefixCls = 'ivu-select-item';
export default {
props: {
value: {
type: [String, Number],
required: true
},
label: {
type: [String, Number]
},
disabled: {
type: Boolean,
default: false
}
},
componentName: 'select-item',
data () {
return {
selected: false,
index: 0, // for up and down to focus
|
e4ebd304
梁灏
update Select com...
|
26
27
28
|
isFocus: false,
hidden: false, // for search
searchLabel: '' // the value is slot,only for search
|
b0893113
jingsam
add eslint
|
29
|
};
|
e355dd49
梁灏
add Select Component
|
30
31
32
33
34
35
36
37
38
39
|
},
computed: {
classes () {
return [
`${prefixCls}`,
{
[`${prefixCls}-disabled`]: this.disabled,
[`${prefixCls}-selected`]: this.selected,
[`${prefixCls}-focus`]: this.isFocus
}
|
b0893113
jingsam
add eslint
|
40
|
];
|
e355dd49
梁灏
add Select Component
|
41
42
|
},
showLabel () {
|
b0893113
jingsam
add eslint
|
43
|
return (this.label) ? this.label : this.value;
|
e355dd49
梁灏
add Select Component
|
44
45
46
47
48
49
50
51
52
53
54
55
|
}
},
methods: {
select () {
if (this.disabled) {
return false;
}
this.$dispatch('on-select-selected', this.value);
},
blur () {
this.isFocus = false;
|
e4ebd304
梁灏
update Select com...
|
56
57
58
|
},
queryChange (val) {
this.hidden = !new RegExp(val, 'i').test(this.searchLabel);
|
e355dd49
梁灏
add Select Component
|
59
60
61
|
}
},
ready () {
|
e4ebd304
梁灏
update Select com...
|
62
|
this.searchLabel = this.$el.innerHTML;
|
e355dd49
梁灏
add Select Component
|
63
64
65
66
|
},
events: {
'on-select-close' () {
this.isFocus = false;
|
e4ebd304
梁灏
update Select com...
|
67
68
69
|
},
'on-query-change' (val) {
this.queryChange(val);
|
e355dd49
梁灏
add Select Component
|
70
71
|
}
}
|
b0893113
jingsam
add eslint
|
72
73
|
};
</script>
|