Bug Type:Component
Environment
- Vue Version:
3.2.31
- Element Plus Version:
2.1.10
- Browser / OS:
Chrome/100.0.4896.127 / Windows 10
- Build Tool:
Vue CLI
Reproduction
Related Component
el-autocomplete
Reproduction Link
Element Plus Playground
Steps to reproduce
Click on the el-autocomplete component to get the exception from console.
It only happens when fetchSuggestions is an async function. Exception gets triggered by the code line:
element-plus/packages/components/autocomplete/src/autocomplete.vue
Line 189 in 5068528
| | result.then(cb) |
From the doc, fetched suggestions need to be committed via the callback function. But in the code of component el-autocomplete, the callback function gets invoked again after fetchSuggestions
finished. Is it necessary?
const result = props.fetchSuggestions(queryString, cb);
if (isArray(result)) {
cb(result)
} else if (isPromise(result)) {
result.then(cb)
}
What is Expected?
Works without exception
What is actually happening?
Throw exceptions
Additional comments
- (empty)*
4条答案
按热度按时间oxcyiej71#
maybe some question #7278
bpzcxfmw2#
playground
Maybe it should be written that way.
wgmfuz8q3#
Yeah, this resolved the exception. I am thinking that, the
cb
will be invoked afterfetch-suggestions
, if we as the users invoked thecb
as method parameter insidefetch-suggestions
, that means in this case thecb
will be invoked twice. Maybe this part can be improved?yhived7q4#
Yeah, this resolved the exception. I am thinking that, the
cb
will be invoked afterfetch-suggestions
, if we as the users invoked thecb
as method parameter insidefetch-suggestions
, that means in this case thecb
will be invoked twice. Maybe this part can be improved?follow #7315