我当前项目中有很多React组件.如果我决定在Om中编写下一个项目,是否可以重用这些组件? 对的,这是可能的.我创建了一个日期组件,我有四个实例.一个用于选择一天,另一个用于选择一周
所以,当我创建它们时,我传入一个映射来配置它们:
(om/build common/column-input-date {:component-id :selected-daily-date}) (om/build common/column-input-date {:component-id :selected-weekly-date}) (om/build common/column-input-date {:component-id :selected-monthly-date}) (om/build common/column-input-date {:component-id :selected-jobs-date})
然后在组件中:
(defn column-input-date [data owner] "column input date" (reify om/IInitState (init-state [_] {:e-map {:display (:display data) :component-id (:component-id data)}}) om/IDidMount
除此之外,页面,一切都是一个组件,所以我有大约20个组件.我通过core.async进行通信,并从ref-cursors获取数据.我尝试将数据传递到组件树中,并确定它是过度耦合的.