关键字高亮
https://github.com/bvaughn/react-highlight-words
pnpm add react-highlight-words
import React from 'react';
import Highlighter from "react-highlight-words";
const App: React.FC = () => {
return (
<Highlighter
highlightClassName="YourHighlightClass"
searchWords={["and", "or", "the"]}
autoEscape={true}
textToHighlight="The dog is chasing the cat. Or perhaps they're just playing?"
/>
)
}
export default App