element/packages/select/src/option-group.vue

61 lines
1.1 KiB
Vue
Raw Normal View History

2016-07-27 06:15:02 +00:00
<template>
2017-11-12 03:56:21 +00:00
<ul class="el-select-group__wrap" v-show="visible">
<li class="el-select-group__title">{{ label }}</li>
2016-07-28 10:37:14 +00:00
<li>
<ul class="el-select-group">
<slot></slot>
</ul>
</li>
</ul>
2016-07-27 06:15:02 +00:00
</template>
<script type="text/babel">
2016-10-27 09:31:22 +00:00
import Emitter from 'element-ui/src/mixins/emitter';
2016-07-27 06:15:02 +00:00
export default {
2016-10-27 09:31:22 +00:00
mixins: [Emitter],
2016-07-27 06:15:02 +00:00
name: 'ElOptionGroup',
2016-07-27 06:15:02 +00:00
componentName: 'ElOptionGroup',
2016-07-27 06:15:02 +00:00
props: {
label: String,
disabled: {
type: Boolean,
default: false
}
},
data() {
return {
visible: true
};
},
2016-10-25 10:00:39 +00:00
watch: {
disabled(val) {
2016-11-26 07:18:38 +00:00
this.broadcast('ElOption', 'handleGroupDisabled', val);
2016-10-25 10:00:39 +00:00
}
},
methods: {
queryChange() {
this.visible = this.$children &&
Array.isArray(this.$children) &&
this.$children.some(option => option.visible === true);
}
},
created() {
this.$on('queryChange', this.queryChange);
},
2016-09-10 02:01:48 +00:00
mounted() {
2016-07-27 06:15:02 +00:00
if (this.disabled) {
2016-11-26 07:18:38 +00:00
this.broadcast('ElOption', 'handleGroupDisabled', this.disabled);
2016-07-27 06:15:02 +00:00
}
}
};
</script>