【发布时间】:2022-10-07 13:54:07
【问题描述】:
我的搜索栏工作正常,但在搜索输入中写了一些内容后,文本没有突出显示。
`<tbody className=\'\'>
{onlineUserData
?.filter((onlineUserInfo) => {
if (searchTerm === \"\") {
return onlineUserInfo
}
else if (
(onlineUserInfo.userName.toLowerCase().replace(/\\s+/g, `<mark>${\'\'}</mark>`).includes(searchTerm.toLowerCase().replace(/\\s+/g, `<mark>${\'\'}</mark>`))) ||
(onlineUserInfo.userStandard.toLowerCase().replace(/\\s+/g, \'\').includes(searchTerm.toLowerCase().replace(/\\s+/g, \'\'))) ||
(onlineUserInfo.userRole.toLowerCase().replace(/\\s+/g, \'\').includes(searchTerm.toLowerCase().replace(/\\s+/g, \'\'))) ||
(onlineUserInfo.userEmail.toLowerCase().replace(/\\s+/g, \'\').includes(searchTerm.toLowerCase().replace(/\\s+/g, \'\'))) ||
(onlineUserInfo.loginTime.toLowerCase().replace(/\\s+/g, \'\').includes(searchTerm.toLowerCase().replace(/\\s+/g, \'\')))
) {
return onlineUserInfo
}
})
?.map((onlineUserInfo, index) => (
<tr className=\"\" key={index}>
<td className=\'\'>{onlineUserInfo.serialNumber}.</td>
<td className=\'\'>{onlineUserInfo.userName}</td>
<td className=\'\'>{onlineUserInfo.userStandard === \"\" ? \"N/A\" : onlineUserInfo.userStandard}</td>
<td className=\'\'>{onlineUserInfo.userRole}</td>
<td className=\'\'>{onlineUserInfo.userEmail}</td>
<td className=\'\'>{onlineUserInfo.loginTime}</td>
</tr>
))}
</tbody>`
我在 userName 行中使用了 Mark 标记,只是为了检查它是否正常工作。但事实并非如此。