我是 Clojure/Clojurescript 和 Om 的新手,经过一番挣扎,我想出了这种方法来从 2d 矢量渲染表格:
(def app-state (atom {:world [[1 2 1] [2 1 1] [1 2 1]]}))
(defn cell
[text]
(om/component
(dom/td nil text)))
(defn row
[data]
(om/component
(apply dom/tr nil
(om/build-all cell data))))
(defn world-view
[data owner]
(om/component
(apply dom/table nil
(om/build-all row (:world data)))))
(om/root
world-view
app-state
{:target (. js/document (getElementById "app"))})
我正在寻找有关如何使其更简洁或如何从一个组件函数创建整个表的指针。