1

The way to style and Om component is based on how React handles styling. It would be a horrible mess to duplicate common CSS rules all over the application so is there a way to define the styles in a function or similar?

(defn my-css [] {:border "1px solid #000"})

(defn my-component [state]
  (dom/div #js {:className "the-class-name"
                :style #js (my-css)}))

I've tried using defn and def but I can't find a way to avoid

Caused by: clojure.lang.ExceptionInfo: JavaScript literal must use map or vector notation

4

1 回答 1

2

我用:

(defn create-style [row]
  {:background-color (utils/get-background-color (:task_status row)) :color (utils/get-color (:task_status row))})

但我将它与“om-bootstrap”一起使用。

我有时在 :style 映射之前有 #js,有时在之后。我认为这取决于他们图书馆的期望。

于 2015-03-28T22:10:58.887 回答