我剛學試劑Clojurescript,我只是遵循一些教程,但也許我錯過了什麼我有這樣的代碼爲國家正確操作狀態試劑
(defonce app-state (atom {:text "Hello Chestnut!" :click-count 0}))
和渲染視圖
(defn article []
[:div
[:div "The atom" [:code "click-count"] " has value : " (:click-count @app-state)]
[:input {:type "button" :value "Add"
:on-click #(swap! (:click-count @app-state) inc)}]
]
)
我試圖增加按鈕按下時的狀態,但我在控制檯上發現了這個錯誤
Error: No protocol method ISwap.-swap! defined for type number: 0
有用的文檔:https://clojuredocs.org/clojure.core/swap! – Bill
我讀過了,但是謝謝:) – Ampersanda