我正在尝试将带有 CSS 的 HTML 解析为 Reagent 项目中的 Hiccup。我正在使用山核桃。当我使用内联 CSS 解析 HTML 时,React 会抛出异常。
(map
as-hiccup (parse-fragment "<div style='color:red'>test</div>")
)
以上生成[:div {:style color:red} "test"]
& Reactjs 从 Reactjs 返回异常:
Violation: The style prop expects a mapping from style properties to values, not a string.
我相信[:div {:style {"color" "red"}} "test"]
必须退回。
这是代码视图:
(ns main.views.job
(:require [reagent.core :as reagent :refer [atom]]
[hickory.core :refer [as-hiccup parse parse-fragment]]))
(enable-console-print!)
(defn some-view [uid]
[:div
(map as-hiccup (parse-fragment "<div style='color:red'>test</div>"))
])