我不明白以下代码中的标签“:<>” clojure re-frame todomvc
(defn todo-app
[]
[:<>
[:section#todoapp
[task-entry]
(when (seq @(subscribe [:todos]))
[task-list])
[footer-controls]]
[:footer#info
[:p "Double-click to edit a todo"]]])
Run Code Online (Sandbox Code Playgroud)
谁可以帮我这个事?
在前面的答案中添加更多细节,将fragment被拼接到周围的列表中,而不是创建子元素。这样一来,与常规运算符相比,它就类似于unquoted-splicingClojure 中的运算符。一个例子:~@unquote~
(defn middle-seq [] [ :d :e :f])
(defn middle-seq-frag [] [:<> :d :e :f])
Run Code Online (Sandbox Code Playgroud)
当用于创建试剂组件时,我们看到了差异:
[:a :b :c (middle-seq) :g :h :i] ;=> [:a :b :c [:d :e :f] :g :h :i]
[:a :b :c (middle-seq-frag) :g :h :i] ;=> [:a :b :c :d :e :f :g :h :i]
Run Code Online (Sandbox Code Playgroud)
否则,您将不得不重组输入并使用concat:
(vec
(concat
[:a :b :c]
(middle-seq)
[:g :h :i] )) ;=> [:a :b :c :d :e :f :g :h :i]
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
262 次 |
| 最近记录: |