30秒学会 React 片段 – AutoLink
Renders a string as plaintext, with URLs converted to appropriate <a>
elements.
- Use
String.prototype.split()
andString.prototype.match()
with a regular expression to find URLs in a string. - Return a
<React.Fragment>
with matched URLs rendered as<a>
elements, dealing with missing protocol prefixes if necessary, and the rest of the string rendered as plaintext.
继续阅读 30秒学会 React 片段 – AutoLink