使用React组件突出一个文本中的关键词的教程

899 阅读1分钟

Highlight A Keyword In A Piece Of Text

一个React组件,可以高亮显示一段文本中的关键词并返回一个React元素。

如何使用它

1.安装和导入。

# NPM
$ npm i react-keywords
import React from 'react';
import Keywords from 'react-keywords';

2.基本用法。

export default function Demo() {
  return (
    <Keywords value="react">
      Your Text Here
    </Keywords>
  );
}

预览

Highlight A Keyword In A Piece Of Text

The postHighlight A Keyword in a Piece of Textappeared first onReactScript.