修复我的列表搜索输入某些字符会导致应用崩溃的问题

This commit is contained in:
lyswhut
2021-10-03 10:55:09 +08:00
parent 6b71b4709e
commit 2fe213d060
2 changed files with 2 additions and 14 deletions
@@ -239,7 +239,7 @@ export default {
handleSearch() {
if (!this.text.length) return this.resultList = []
let list = []
let rxp = new RegExp(this.text.split('').join('.*') + '.*', 'i')
let rxp = new RegExp(this.text.split('').map(s => s.replace(/[.*+?^${}()|[\]\\]/, '\\$&')).join('.*') + '.*', 'i')
for (const item of this.list) {
if (rxp.test(`${item.name}${item.singer}${item.albumName ? item.albumName : ''}`)) list.push(item)
}