将更改字符串响应到组件(多个)



我想制作像 Wiki 这样的自定义语法,如何在 React 中做到这一点而没有dangerouslySetInnerHTML

例如:

"你好,这是简单的字符串 [linkToSomewhere] {这是粗体去的地方}">

成为

<div>
  hello this is simple string <Link where="linktoSomewhere"/> <Bold string="this is where bold goes"/>
</div>

喜欢这个

我找到了将自定义降价解析为数组的方法,但找不到插入它的方法,因为反应组件数组就像

link[0] = "linkToSomewhere"
bold[0] = "this is where Bold goes"

提前谢谢你!

有一些 Markdown 库可用于 React。退房:

  • 反应降价:https://rexxars.github.io/react-markdown/
  • 反应显著:https://github.com/acdlite/react-remarkable

这里有一大堆其他库可以将您的 Markdown 文档转换为呈现良好的 HTML:https://react.rocks/tag/Markdown

为了学习 Markdown 语法,有一些备忘单可用,例如:

  • http://assemble.io/docs/Cheatsheet-Markdown.html
  • https://guides.github.com/pdfs/markdown-cheatsheet-online.pdf

最新更新