Commit 80bec51 zhiyang
committed
1 parent df7bbe2 commit 80bec51 Copy full SHA for 80bec51
File tree 1 file changed +12
-5
lines changed
packages/autocomplete/src
1 file changed +12
-5
lines changed Original file line number Diff line number Diff line change 122
122
activated: false ,
123
123
suggestions: [],
124
124
loading: false ,
125
- highlightedIndex: - 1
125
+ highlightedIndex: - 1 ,
126
+ suggestionDisabled: false
126
127
};
127
128
},
128
129
computed: {
150
151
};
151
152
},
152
153
getData (queryString ) {
154
+ if (this .suggestionDisabled ) {
155
+ return ;
156
+ }
153
157
this .loading = true ;
154
158
this .fetchSuggestions (queryString, (suggestions ) => {
155
159
this .loading = false ;
160
+ if (this .suggestionDisabled ) {
161
+ return ;
162
+ }
156
163
if (Array .isArray (suggestions)) {
157
164
this .suggestions = suggestions;
158
165
} else {
159
- console .error (' autocomplete suggestions must be an array' );
166
+ console .error (' [Element Warn][Autocomplete] autocomplete suggestions must be an array' );
160
167
}
161
168
});
162
169
},
163
170
handleChange (value ) {
164
171
this .$emit (' input' , value);
172
+ this .suggestionDisabled = false ;
165
173
if (! this .triggerOnFocus && ! value) {
174
+ this .suggestionDisabled = true ;
166
175
this .suggestions = [];
167
176
return ;
168
177
}
228
237
}
229
238
},
230
239
mounted () {
231
- this .debouncedGetData = debounce (this .debounce , (val ) => {
232
- this .getData (val);
233
- });
240
+ this .debouncedGetData = debounce (this .debounce , this .getData );
234
241
this .$on (' item-click' , item => {
235
242
this .select (item);
236
243
});
You can’t perform that action at this time.
0 commit comments