【发布时间】:2021-02-27 03:30:49
【问题描述】:
我正在尝试使用 Fuse.js 实现搜索栏。
const fuse = new Fuse(rows, searchOptions);
let searchResults = fuse.search(e);
console.log(searchResults);
if (searchResults.length > 0) {
rows.forEach(function (item, index) {
item.style.display = "none";
searchResults.forEach(function (searchHit, hitIndex) {
if (searchHit.item == item)
item.style.display = "flex";
});
});
}
当代码运行时,没有任何可见的事情发生。 如果我用 item.style.color 替换 item.style.display 并尝试更改颜色,它会识别正确的卡片并正确着色。
我尝试添加“!important”,但结果保持不变。我也尝试过 $(item).hide() 徒劳无功。
【问题讨论】:
标签: javascript html jquery css dom