fix: value option no set
This commit is contained in:
parent
968aa04aa9
commit
42e545dd66
1 changed files with 16 additions and 2 deletions
|
|
@ -35,7 +35,13 @@ export const createSelect = <T extends Record<string, any>>(
|
|||
let previousSearch = '';
|
||||
|
||||
watch(value, (v) => {
|
||||
if (!v || (cache && cache.find((opt) => opt[valueField] === v))) return;
|
||||
if (!v) return;
|
||||
|
||||
if (cache && cache.find((opt) => opt[valueField] === v)) {
|
||||
valueOption.value = cache.find((opt) => opt[valueField] === v);
|
||||
return;
|
||||
}
|
||||
|
||||
getSelectedOption();
|
||||
});
|
||||
|
||||
|
|
@ -63,7 +69,15 @@ export const createSelect = <T extends Record<string, any>>(
|
|||
const currentValue = value.value;
|
||||
|
||||
if (!currentValue) return;
|
||||
if (selectOptions.value.find((v) => v[valueField] === currentValue)) return;
|
||||
|
||||
const option = selectOptions.value.find(
|
||||
(v) => v[valueField] === currentValue,
|
||||
);
|
||||
|
||||
if (option) {
|
||||
valueOption.value = option;
|
||||
return;
|
||||
}
|
||||
if (valueOption.value && valueOption.value[valueField] === currentValue) {
|
||||
return selectOptions.value.unshift(valueOption.value);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue