如果我有以下代码和一个从“p”标记切换到“h1”标记的函数:
(def switch-tag (cell p))
((cell= switch-tag) "Text goes here")
我一直无法用你的方式解决这个问题。这里有一个解决方法:
(page "index.html") (def key! (cell true)) (defelem my-elem [_ [child]] (cell= (if key! (h1 child) (p child)))) (html (body (button :click #(swap! key! not) "test") (my-elem "this is a test")))