声明式 DOM 库 freactive

EPL
跨平台
2014-11-25
红薯

freactive 是一个高性能、纯 Clojurescript 实现的声明式 DOM 库。使用 hiccup 风格的语法和 Clojure 内建的 deref 和 atom 模式。灵感来自于 reagent, omreflex 

示例代码:

(ns example1
  (:refer-clojure :exclude [atom])
  (:require [freactive.core :refer [atom cursor]]
            [freactive.dom :as dom])
  (:require-macros [freactive.macros :refer [rx]]))

(defonce mouse-pos (atom nil))

(defn view []
  [:div
    {:width "100%" :height "100%" :style {:border "1px solid black"}
     :on-mousemove (fn [e] (reset! mouse-pos [(.-clientX e) (.-clientY e)]))}
    [:h1 "Hello World!"]
    [:p "Your mouse is at: " (rx (str @mouse-pos))]])

(defonce root (dom/append-child! (.-body js/document) [:div#root]))

(dom/mount! root (view))

加载中

评论(0)

暂无评论

暂无资讯

暂无问答

暂无博客

返回顶部
顶部