2017-02-09 7 views
2

appendChild試薬要素の作成方法は?たとえば

(defn place-background [] 
     [:div {:class "pbackground" 
      :style {:height (:fullheight @app-state)}}]) 

    (reagent/render-appendChild [place-background] 
          (. js/document (getElementById "container"))) 

私はレンダリングコンポーネントを使用する場合、それはコンテンツ

答えて

2
(ns reagenttest.core 
    (:require [reagent.core :as r])) 


(defn sample-comp [] 
    [:div "hello there!"]) 

(defn appended-container [target] 
    (let [id "some-unique-id" 
      container (.getElementById js/document id)] 

     (if container 
      container 
      (.appendChild target (doto (.createElement js/document "div") 
            (-> (.setAttribute "id" id)))) 
      ))) 

(r/render [sample-comp] (appended-container (.getElementById js/document "app"))) 
+0

しかし、私は、複製したい場合に置き換えられますので、?例えば、 (draw {:width "200px:height" 200px "}) (draw {:width" 200px:height "200px"})のように、 –

関連する問題