Recursion 让递归组件在Om中工作时出现问题?
我有以下资料:Recursion 让递归组件在Om中工作时出现问题?,recursion,clojure,clojurescript,om,Recursion,Clojure,Clojurescript,Om,我有以下资料: (ns commentz.client (:require [om.core :as om :include-macros true] [om.dom :as dom :include-macros true] [clojure.browser.repl])) (def app-state (atom {:id "a" :value "I am the greatest of comments!" :user "1
(ns commentz.client
(:require
[om.core :as om :include-macros true]
[om.dom :as dom :include-macros true]
[clojure.browser.repl]))
(def app-state
(atom
{:id "a"
:value "I am the greatest of comments!"
:user "1"
:anonymous false
:score 10
:children
[{:value "I am ok too."
:user "1"
:anonymous false
:score 4
:children
[{:value "I am the second greatest comment"
:user "2"
:anonymous false
:score 7
:children {}}]}
{:value "I like turtles"
:user "3"
:anonymous true
:score -3
:children {}}]}))
(defn header [app owner]
(dom/div #js {:className "header"}
(dom/div #js {:className "vote"}
(dom/div #js {:className "up"})
(dom/div #js {:className "down"}))
(dom/a #js {:className "username" :href (:user app)} (:user-name app))
(dom/div #js {:className "score"} (:score app))))
(defn footer [app owner]
(dom/div #js {:className "footer"}
(dom/a #js {:className "permalink" :href (str "#" (:id app))} "permalink")
(dom/a #js {:className "reply"} "reply")))
(defn comment [app owner]
(reify
om/IRender
(render [this]
(dom/div {:id (:id app) :className "comment"}
(header app owner)
(dom/div #js {:className "value"} (:value app))
(footer app owner)
(om/build-all comment (:children app))))))
(om/root comment app-state {:target (. js/document (getElementById "app"))})
上面的代码确实成功地编译了,但我没有看到任何递归的东西。相反,当我使用浏览器进行检查时,我看到了以下内容
10
I am the greatest of comments!
permalink reply
0 32374988
我认为32374988可能是一个对象散列,不确定0是关于什么的。无论如何,我的目的是看到所有4条注释都显示出来,其中一些注释嵌套在其他注释中。目前,我只得到根注释,加上一些奇怪的032374988
递归构建的注释应该在哪里。感谢您的帮助。谢谢。(om/build all)
返回一个seq。尝试(应用dom/div nil…
我犯了同样的错误,我是通过谷歌搜索“32374988”来这里的
(apply dom/div {:id (:id app) :className "comment"}
(header app owner)
(dom/div #js {:className "value"} (:value app))
(footer app owner)
(om/build-all comment (:children app))))))