我的devcards曾经使用过Figwheel。但是我无法让它们与shadow-cljs一起显示。
暗影发出此消息:
shadow-cljs - HTTP服务器:http://localhost:3450
时可用的卡片
命名空间cards.card-ui
只是一系列要求。
我在println
中显示了cards.card-ui
消息。
在shadow-cljs.edn
我有两个:builds
。这是第二个:
:cards {:target :browser
:output-dir "resources/public/js/cards"
:asset-path "js/cards"
:modules {:main {:entries [cards.card-ui]}}
:compiler-options {:static-fns false}
:devtools {:http-root "resources/public"
:http-resource-root "resources/public"
:http-port 3450
:http-handler shadow.http.push-state/handle
:push-state/index "cards.html"
:preloads [devtools.preload
default-db-format.preload]}
:dev {:compiler-options {:devcards true}}
}
cards.html
有一个body标签,其div标签的ID为“app”。我将浏览器带到http://localhost:3450/cards.html
并获得一个空白页面。我最好的理论是cards.card-ui
没有挂载app
命名空间。
答案 0 :(得分:1)
目前获得使用shadow-cljs而不是Figwheel的示例Fulcro应用程序的唯一方法是通过lein模板。所以在命令提示符下:
lein new fulcro app shadow-cljs
此处app
是您选择的任何名称,shadow-cljs
是一个选项。在研究了生成的应用程序之后,我意识到命名空间cards.card-ui
不应该只是一个需求列表,而是需要这些行:
(devcards.core/start-devcard-ui!)
(defn refresh []
(println "In cards.card-ui that starts the ui"))
:cards
中的shadow-cljs.edn
版本变得更简单了:
:cards {:target :browser
:output-dir "resources/public/js/cards"
:asset-path "js/cards"
:compiler-options {:devcards true}
:modules {:main
{:entries [cards.card-ui]}}
:devtools {:after-load cards.card-ui/refresh
:http-root "resources/public"
:http-port 3450}
}
我错的另一件事是HTML(cards.html
)。这里只是标记的body
标记:
<body>
<div id="app"></div>
<script src="js/cards/main.js"></script>
</body>
Devcards网站的一些导入指针:https://github.com/bhauman/devcards#usage-without-figwheel
lein模板项目:https://github.com/fulcrologic/fulcro-lein-template