clojurescript - 如何让 CKEditor react 组件在 ClojureScript 中可用
问题描述
我无法让 CKEditor 反应组件在 ClojureScript 项目中工作。
当我尝试使用组件时
(ns simple.core
(:require [reagent.core :as reagent]
[re-frame.core :as rf]
[clojure.string :as str]
[simple.routes :as routes]
["ckeditor4-react" :as ck :default CKEditor]
))
...
[:> CKEditor]
我明白了
template.cljs:312 Uncaught Error: Assert failed: Expected React component in: [:> nil]
(in simple.core.ui)
(or (string? comp) (fn? comp))
at Object.reagent$impl$template$vec_to_elem [as vec_to_elem] (template.cljs:312)
at Object.reagent$impl$template$as_element [as as_element] (template.cljs:329)
at template.cljs:403
at core.cljs:5598
at core.cljs:5598
at Object.cljs$core$IKVReduce$_kv_reduce$arity$3 (core.cljs:5602)
at Object.cljs$core$_kv_reduce [as _kv_reduce] (core.cljs:700)
at Object.cljs$core$reduce_kv [as reduce_kv] (core.cljs:2543)
at reagent$impl$template$make_element (template.cljs:401)
at Object.reagent$impl$template$native_element [as native_element] (template.cljs:285)
我创建了一个简单的 github 项目来说明。
https://github.com/madhat2r/shadow-re-frame-simple-example
如果您克隆它并按照自述文件中的说明进行操作,则可以复制。
谢谢你的帮助!
解决方案
原来这是你必须使用的:require
使用问题:default
["ckeditor4-react" :as CKEditor]
...
[:> CKEditor {:onBeforeLoad (fn [ck] (set! (.-disableAutoInline ck) true))}]
影子-cljs:https ://shadow-cljs.github.io/docs/UsersGuide.html#_about_default_exports
注意:上面的 onBeforeLoad 函数修复了当前版本的错误。留给任何可能遇到它的人。https://github.com/ckeditor/ckeditor4-react/issues/57
推荐阅读
- swift - 当 JSON 的名称中包含带有“-”的字符串时,如何使用 Decodable 解析 JSON
- java - Java 错误打开注册表项“软件\JavaSoft\Java 运行时环境”
- jquery - 有什么方法可以在我单击图像时显示切换菜单?
- parsing - 评估解析的复杂性以及从哪些参数发布工作成本的标准是什么?
- flutter - 有没有办法将 CustomPainter 的 Path 和 Paint 存储在颤动中?
- android-studio - 如何修复 OpenCV 在 Android Studio 中的导入错误?
- android - 按下按钮时如何使 StateListDrawable 更改背景?(在 xml 中)
- mysql - 为什么我的 Insert Into 语句不能正常工作
- json - 如何将 Json.Decode.Value 解码为 elm 0.19 中的标记联合类型?
- r - 如何在 R 中绘制线性和逆回归拟合线?