Use ckeditor with React

#1

在React里使用ckeditor遇到问题,有没有react里用过ckeditor的帮忙解答一下?

用npm安装package: npm install ckeditor
在component里,使用ckeditor:

 import CKEDITOR from 'ckeditor'; 

 componentDidMount() {
    CKEDITOR.replace( 'editor1' );
}

这是我的textarea:

<textarea ref="editor1" id="editor1" rows="10" cols="80"/>

每次都得到这个报错:

Uncaught TypeError: _ckeditor2.default.replace is not a function
#2

你没安装成功吧。npm install ckeditor --save 后面你要加参数是全局安装还是只是这个项目;

#3

只是这个项目用,我也试着在html里全局引用也不行

#4

同样的错误,:sweat_smile:

#5

我全局引用了,是可以正常使用的,你误导我啊

#6

查了一下ckeditor最新的代码,它并不支持模块化引用。。。
除非你改造一下它源码,才能使用import或者require
现在就老老实实全局引用吧

#7

我全局引用显示“ CKEDITOR is not defined”,你是怎么引用的啊?

#8

是不是在index.html里这样引用的?
<script src="./node_modules/ckeditor/ckeditor.js"></script>

#9

请问怎么全局引入的,求指导