iview/src/components/select/option-group.vue

48 lines
1.3 KiB
Vue
Raw Normal View History

<template>
2017-01-13 16:46:20 +08:00
<li :class="[prefixCls + '-wrap']" v-show="!hidden">
2016-10-28 17:24:52 +08:00
<div :class="[prefixCls + '-title']">{{ label }}</div>
<ul>
2017-01-13 16:46:20 +08:00
<li :class="[prefixCls]" v-el:options><slot></slot></li>
</ul>
</li>
</template>
<script>
const prefixCls = 'ivu-select-group';
export default {
props: {
label: {
type: String,
default: ''
}
},
data () {
return {
2017-01-13 16:46:20 +08:00
prefixCls: prefixCls,
hidden: false // for search
2016-12-25 22:49:42 +08:00
};
2017-01-13 16:46:20 +08:00
},
methods: {
queryChange () {
this.$nextTick(() => {
const options = this.$els.options.querySelectorAll('.ivu-select-item');
let hasVisibleOption = false;
for (let i = 0; i < options.length; i++) {
if (options[i].style.display !== 'none') {
hasVisibleOption = true;
break;
}
}
this.hidden = !hasVisibleOption;
});
}
},
events: {
'on-query-change' () {
this.queryChange();
return true;
}
}
2016-12-25 22:49:42 +08:00
};
2016-10-28 17:24:52 +08:00
</script>