🐛 修复特定情况下的索引异常

This commit is contained in:
目棃
2024-08-26 16:24:36 +08:00
parent 6e040ebe48
commit 6223280ffe

View File

@@ -144,6 +144,11 @@ watch(resetSelect, (val) => {
text: "已重置筛选条件",
color: "success",
});
selectIndex.value = selectedList.value.indexOf(dataVal.value);
if (selectIndex.value === -1) {
dataVal.value = selectedList.value[0];
selectIndex.value = 0;
}
}
});
watch(showMode, (val) => {
@@ -328,6 +333,8 @@ function handleSelect(val: SelectedCValue) {
if (!selectedList.value.includes(dataVal.value)) {
dataVal.value = selectedList.value[0];
selectIndex.value = 0;
} else {
selectIndex.value = selectedList.value.indexOf(dataVal.value);
}
}