瀏覽代碼

fix autocomplete dropdown reference element (#2092)

baiyaaaaa 8 年之前
父節點
當前提交
a2fd24e0f5
共有 2 個文件被更改,包括 3 次插入2 次删除
  1. 1 1
      packages/autocomplete/src/autocomplete-suggestions.vue
  2. 2 1
      packages/autocomplete/src/autocomplete.vue

+ 1 - 1
packages/autocomplete/src/autocomplete-suggestions.vue

@@ -55,7 +55,7 @@
 
     mounted() {
       this.popperElm = this.$el;
-      this.referenceElm = this.$parent.$el;
+      this.referenceElm = this.$parent.$refs.input.$refs.input;
     },
 
     created() {

+ 2 - 1
packages/autocomplete/src/autocomplete.vue

@@ -1,6 +1,7 @@
 <template>
   <div class="el-autocomplete" v-clickoutside="handleBlur">
     <el-input
+      ref="input"
       :value="value"
       :disabled="disabled"
       :placeholder="placeholder"
@@ -69,7 +70,7 @@
     },
     watch: {
       suggestionVisible(val) {
-        this.broadcast('ElAutocompleteSuggestions', 'visible', [val, this.$el.offsetWidth]);
+        this.broadcast('ElAutocompleteSuggestions', 'visible', [val, this.$refs.input.$refs.input.offsetWidth]);
       }
     },
     methods: {