ホームページにテキストボックスを作成したいので、次のように書きました。
(defn home-page []
[:div.container
[:h1 "Enter Code:"]
[c/text-input "id" :id "enter code" fields]])
c/text-input は、必要な別の名前空間 (common.cljs) に含まれています。
common.cljs 名前空間のコードは次のとおりです。
(defn input [type id placeholder fields]
[:input.form-control.input-lg
{:type type
:placeholder placeholder
:value (id @fields)
:on-change #(swap! fields assoc id (-> % .-target .-value))}])
(defn form-input [type label id placeholder fields optional?]
[:div.form-group
[:label label]
(if optional?
[input type id placeholder fields]
[:div.input-group
[input type id placeholder fields]
[:span.input-group-addon
"✱"]])])
(defn text-input [label id placeholder fields & [optional?]]
(form-input :text label id placeholder fields optional?))
[c/text-input "id" :id "enter code" fields]]
ただし、コードから削除すると、Web ページが通常どおり読み込まれるという問題が発生します。このコード行では何も起こりません。
私は自分の間違いを理解できず、助けていただければ幸いです。
(PSが役立つ場合は、luminusフレームワークを使用しています)