Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在使用 ClojureScript 试剂。它提供了类似打嗝的 HTML 生成。
我有一个带有 HTML 的字符串:
(def code "<b>hello world</b>")
当传递给 Hiccup 时,它将被转义,并且我的页面上没有粗体文本:
[:div code]
如何传递code给我的 HTML 输出,以便将其集成到那里而不会被转义?
code
使用本dangerouslysetInnerHTML机 React 调用
dangerouslysetInnerHTML
[:div {:dangerouslySetInnerHTML {:__html code}}])
您需要使用以下raw-string功能hiccup.utils:
raw-string
hiccup.utils
[:div (raw-string code)]