iframe
分支下实现了它。它有一些使用 re-frame 的示例 devcards。[org.clojars.nberger/devcards "0.2.3-0-iframe"]
的形式发布在 clojars 上,但它需要一些工作来提供更友好的方法来创建 iframe devcards,也许还需要针对 re-frame 的 devcard 宏。此外,可能还需要优化一些 UI 界面。但请随意使用它。当然,我们欢迎贡献和反馈。
我会在这里放一个示例来展示如何使用它:
(defcard-rg re-frame-component-initialize-db
"This is the same re-frame component, but now using
data-atom to initialize the db, rendered in an iframe:"
(fn [data-atom _]
(setup-example-1)
(re-frame/dispatch [:initialize-db @data-atom])
[re-frame-component-example])
{:guest-name "John"}
{:iframe true})
更新:
我是如何使用figwheel main实现的:
[devcards "0.2.6" ]
添加到您的依赖项中。src/cljs/cards/core.cljs
。dev.cljs.edn
中添加新的extra-main-files部分,并打开devcards功能。 ^{:watch-dirs ["src/cljs" "test"]
:css-dirs ["resources/public/css"]
:auto-testing true
:extra-main-files {:testing {:main menu-planner.test-runner}
:devcards {:main cards.core}} ;; <- this
:open-url false}
{:main menu-planner.core
:infer-externs true
:devcards true ;; <- and this
}
src/cljs/cards/core.cljs
中添加带有 defcard-rg 的卡片(ns cards.core
(:require
[devcards.core]
[re-frame.core :as re-frame])
(:require-macros
[devcards.core :refer [defcard-rg]]))
(devcards.core/start-devcard-ui!)
(defcard-rg no-state
[:div {:style {:border "10px solid blue" :padding "20px"}}
[:h1 "Composing Reagent Hiccup on the fly"]
[:p "adding arbitrary hiccup"]])
(defcard-rg with-state
(fn [data-atom _]
[:div "test"])
{:initial-data "Ta-ta!"})
figwheel-main
。他们说你不能在第一页做到:
re-frame仍然是一个正在进行中的工作,它在某些方面存在不足 - 例如它与devcards的兼容性不如我们所希望的那样好
Test1
出现在哪里?你的代码中有这个字符串吗?欢迎分享一个 gist 或者 repo 来展示这个问题,我可以帮你看一下。 - nberger