0

如果我有以下代码和从“p”标签切换到“h1”标签的功能:

 (def switch-tag (cell p))

后来在 hlsp 中

 ((cell= switch-tag) "Text goes here")

为什么当我切换到 h1 标签时似乎什么也没发生。

4

1 回答 1

1

我一直无法用你的方式解决这个问题。这是一种解决方法:

(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")))
于 2017-10-05T13:50:23.673 回答