fix: 选择器下拉-转义搜索关键字中的所有特殊字符

--bug=1044121 --user=吕梦园
https://www.tapd.cn/55049933/bugtrace/bugs/view/1155049933001044121
This commit is contained in:
teukkk 2024-07-17 15:56:16 +08:00 committed by 刘瑞斌
parent cfcf184a0d
commit cc1a67a47a
1 changed files with 6 additions and 1 deletions

View File

@ -173,7 +173,10 @@ export default defineComponent(
if (e[key]?.toLowerCase().includes(val.toLowerCase())) {
// 是否匹配
hasMatch = true;
item[key] = e[key].replace(new RegExp(val, 'gi'), highlightedKeyword); // 高亮关键字替换
item[key] = e[key].replace(
new RegExp(val.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'), 'gi'), // 转义搜索关键字中的所有特殊字符
highlightedKeyword
); // 高亮关键字替换
}
}
}
@ -189,6 +192,8 @@ export default defineComponent(
return null;
})
.filter((e) => e) as SelectOptionData[];
console.log('filterOptions.value', filterOptions.value);
if (props.shouldCalculateMaxTag !== false && props.multiple) {
calculateMaxTag();
}