我正在尝试在我的网页中嵌入一个CodeMirror来编辑几个代码片段,一次一个。
为了做到这一点,我:
node-defs-atom包含代码片段的映射。node-history-atom,它包含正在查看的片段的键。以下是不起作用的地方:
(defn editor [node-defs-atom node-history-atom]
(reagent/create-class
{:reagent-render (fn [] (do [:textarea
{ :value (@node-defs-atom (last @node-history-atom))
:auto-complete "off"}]))
:component-did-mount (editor-did-mount node-defs-atom node-history-atom)
}))
(defn editor-did-mount [node-defs-atom node-history-atom]
(fn [this]
(let [codemirror (.fromTextArea js/CodeMirror
(reagent/dom-node this)
#js {:mode "clojure"
:lineNumbers true})]
...... )))用node-history-atom更改reset!不会对CodeMirror中的文本产生任何影响。我真的不知道到底出了什么问题。
如果有人能告诉我,我应该把(@node-defs-atom (last @node-history-atom))的参考资料放在哪里,我将非常感激。
提前感谢!
发布于 2016-07-08 10:32:48
您可以尝试另一种方法来处理CodeMirror编辑器
wrapper-id只是父类的id。
(试剂/创建-类{:试剂-呈现(fn [] @cm :div {:id包装-id}) :component-did- update -comp :component装入update-comp})https://stackoverflow.com/questions/38255446
复制相似问题