当我试图在REPL中呈现任何Rum的组件时,它失败了,并显示以下错误消息。我做错了什么?是否存在任何变通方法?
:dependencies [[org.clojure/clojure "1.9.0"]
[org.clojure/clojurescript "1.10.238"]
[rum "0.11.2"]]
...
=> (rum/defc label [text]
[:div {:class "label"} text])
=> (label "foo")
#object[TypeError TypeError: Cannot convert a Symbol value to a string]
Function.cljs.core.str.cljs$core$IFn$_invoke$arity$1 (jar:file:/Users/asotnikov/.m2/repository/org/clojure/clojurescript/1.10.238/clojurescript-1.10.238.jar!/cljs/core.cljs:2944:22)
cljs.core/pr-writer-impl (jar:file:/Users/asotnikov/.m2/repository/org/clojure/clojurescript/1.10.238/clojurescript-1.10.238.jar!/cljs/core.cljs:9994:53)
cljs$core$pr_writer (jar:file:/Users/asotnikov/.m2/repository/org/clojure/clojurescript/1.10.238/clojurescript-1.10.238.jar!/cljs/core.cljs:10003:6)
cljs.core/pr-sequential-writer (jar:file:/Users/asotnikov/.m2/repository/org/clojure/clojurescript/1.10.238/clojurescript-1.10.238.jar!/cljs/core.cljs:9857:16)
cljs.core/print-prefix-map (jar:file:/Users/asotnikov/.m2/repository/org/clojure/clojurescript/1.10.238/clojurescript-1.10.238.jar!/cljs/core.cljs:10121:4)
cljs.core/print-map (jar:file:/Users/asotnikov/.m2/repository/org/clojure/clojurescript/1.10.238/clojurescript-1.10.238.jar!/cljs/core.cljs:10135:8)
cljs.core/pr-writer-impl (jar:file:/Users/asotnikov/.m2/repository/org/clojure/clojurescript/1.10.238/clojurescript-1.10.238.jar!/cljs/core.cljs:9939:12)
cljs$core$pr_writer (jar:file:/Users/asotnikov/.m2/repository/org/clojure/clojurescript/1.10.238/clojurescript-1.10.238.jar!/cljs/core.cljs:10003:6)
从头开始创建项目会得到相同的错误:
bash-3.2$ lein new figwheel hello-world -- --rum
bash-3.2$ cd hello-world/
bash-3.2$ lein figwheel
...
ClojureScript 1.10.238
dev:cljs.user=> (require '[rum.core :as rum])
dev:cljs.user=> (rum/defc label [text]
#_=> [:div {:class "label"} text])
#'cljs.user/label
dev:cljs.user=> (label "foo")
#object[TypeError TypeError: Cannot convert a Symbol value to a string]
Function.cljs.core.str.cljs$core$IFn$_invoke$arity$1 (jar:file:/Users/asotnikov/.m2/repository/org/clojure/clojurescript/1.10.238/clojurescript-1.10.238.jar!/cljs/core.cljs:2944:22)
cljs.core/pr-writer-impl (jar:file:/Users/asotnikov/.m2/repository/org/clojure/clojurescript/1.10.238/clojurescript-1.10.238.jar!/cljs/core.cljs:9994:53)
cljs$core$pr_writer (jar:file:/Users/asotnikov/.m2/repository/org/clojure/clojurescript/1.10.238/clojurescript-1.10.238.jar!/cljs/core.cljs:10003:6)
cljs.core/pr-sequential-writer (jar:file:/Users/asotnikov/.m2/repository/org/clojure/clojurescript/1.10.238/clojurescript-1.10.238.jar!/cljs/core.cljs:9857:16)
cljs.core/print-prefix-map (jar:file:/Users/asotnikov/.m2/repository/org/clojure/clojurescript/1.10.238/clojurescript-1.10.238.jar!/cljs/core.cljs:10121:4)
cljs.core/print-map (jar:file:/Users/asotnikov/.m2/repository/org/clojure/clojurescript/1.10.238/clojurescript-1.10.238.jar!/cljs/core.cljs:10135:8)
cljs.core/pr-writer-impl (jar:file:/Users/asotnikov/.m2/repository/org/clojure/clojurescript/1.10.238/clojurescript-1.10.238.jar!/cljs/core.cljs:9939:12)
cljs$core$pr_writer (jar:file:/Users/asotnikov/.m2/repository/org/clojure/clojurescript/1.10.238/clojurescript-1.10.238.jar!/cljs/core.cljs:10003:6)
这是clojuescrapt的一个已知错误。您可以将其用作临时修复:
(when (exists? js/Symbol)
(extend-protocol IPrintWithWriter
js/Symbol
(-pr-writer [sym writer _]
(-write writer (str """ (.toString sym) """)))))