假设我们有这个网格,其值可以是 0 或 1:
(def grid [[1 0 1]
[1 0 0]
[1 0 1]])
现在我想grid
使用列表理解转换为类似 html Hiccup 的格式:
(defn cell-component [is-it-1 key]
^{:key key} [:td (if (= is-it-1 1) {:class "is-it-1"})])
(defn grid-html []
([:table
[:tbody
(for [row grid]
^{:key row} [:tr
(for [cell row]
(cell-component cell how-i-can-generate-a-index?))])]]))
该表已正确生成,但我对如何unique index
为我的td
. how-i-can-generate-a-index?
应该是什么?