2016-12-29 12:34:03 +00:00
|
|
|
<template>
|
|
|
|
<transition name="el-zoom-in-top" @after-leave="doDestroy">
|
2017-02-06 06:29:53 +00:00
|
|
|
<div
|
2016-12-29 12:34:03 +00:00
|
|
|
v-show="showPopper"
|
2017-09-22 09:46:34 +00:00
|
|
|
class="el-autocomplete-suggestion el-popper"
|
2018-05-21 09:27:42 +00:00
|
|
|
:class="{ 'is-loading': !parent.hideLoading && parent.loading }"
|
2016-12-29 12:34:03 +00:00
|
|
|
:style="{ width: dropdownWidth }"
|
2018-05-21 09:27:42 +00:00
|
|
|
role="region">
|
2017-02-06 06:29:53 +00:00
|
|
|
<el-scrollbar
|
|
|
|
tag="ul"
|
|
|
|
wrap-class="el-autocomplete-suggestion__wrap"
|
2018-05-21 09:27:42 +00:00
|
|
|
view-class="el-autocomplete-suggestion__list">
|
|
|
|
<li v-if="!parent.hideLoading && parent.loading"><i class="el-icon-loading"></i></li>
|
2017-09-25 11:16:16 +00:00
|
|
|
<slot v-else>
|
|
|
|
</slot>
|
2017-02-06 06:29:53 +00:00
|
|
|
</el-scrollbar>
|
|
|
|
</div>
|
2016-12-29 12:34:03 +00:00
|
|
|
</transition>
|
|
|
|
</template>
|
|
|
|
<script>
|
|
|
|
import Popper from 'element-ui/src/utils/vue-popper';
|
2017-01-06 04:00:52 +00:00
|
|
|
import Emitter from 'element-ui/src/mixins/emitter';
|
2017-03-13 15:30:59 +00:00
|
|
|
import ElScrollbar from 'element-ui/packages/scrollbar';
|
|
|
|
|
2016-12-29 12:34:03 +00:00
|
|
|
export default {
|
2017-03-13 15:30:59 +00:00
|
|
|
components: { ElScrollbar },
|
2017-01-06 04:00:52 +00:00
|
|
|
mixins: [Popper, Emitter],
|
2016-12-29 12:34:03 +00:00
|
|
|
|
|
|
|
componentName: 'ElAutocompleteSuggestions',
|
|
|
|
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
parent: this.$parent,
|
|
|
|
dropdownWidth: ''
|
|
|
|
};
|
|
|
|
},
|
|
|
|
|
|
|
|
props: {
|
|
|
|
options: {
|
|
|
|
default() {
|
|
|
|
return {
|
|
|
|
gpuAcceleration: false
|
|
|
|
};
|
|
|
|
}
|
2017-09-29 07:58:07 +00:00
|
|
|
},
|
|
|
|
id: String
|
2016-12-29 12:34:03 +00:00
|
|
|
},
|
|
|
|
|
2017-01-06 04:00:52 +00:00
|
|
|
methods: {
|
|
|
|
select(item) {
|
|
|
|
this.dispatch('ElAutocomplete', 'item-click', item);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2017-02-17 07:26:13 +00:00
|
|
|
updated() {
|
|
|
|
this.$nextTick(_ => {
|
2018-05-14 03:05:29 +00:00
|
|
|
this.popperJS && this.updatePopper();
|
2017-02-17 07:26:13 +00:00
|
|
|
});
|
|
|
|
},
|
|
|
|
|
2016-12-29 12:34:03 +00:00
|
|
|
mounted() {
|
2017-07-17 07:45:57 +00:00
|
|
|
this.$parent.popperElm = this.popperElm = this.$el;
|
2020-04-10 08:46:06 +00:00
|
|
|
this.referenceElm = this.$parent.$refs.input.$refs.input || this.$parent.$refs.input.$refs.textarea;
|
2017-09-29 07:58:07 +00:00
|
|
|
this.referenceList = this.$el.querySelector('.el-autocomplete-suggestion__list');
|
|
|
|
this.referenceList.setAttribute('role', 'listbox');
|
|
|
|
this.referenceList.setAttribute('id', this.id);
|
2016-12-29 12:34:03 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
created() {
|
|
|
|
this.$on('visible', (val, inputWidth) => {
|
|
|
|
this.dropdownWidth = inputWidth + 'px';
|
|
|
|
this.showPopper = val;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
};
|
|
|
|
</script>
|