How to resolve Uncaught TypeError: Cannot read property 'body' of null for tinymce.4.2.7.min.js?

How to resolve Uncaught TypeError: Cannot read property 'body' of null for tinymce.4.2.7.min.js?

我正在使用 react-tinymce 0.2.3 和 tinymce 4.2.7。 根据 handleEditorChange 中的以下代码,在调用 e.target.getContent() 后出现错误

tinymce.4.2.7.min.js:10 Uncaught TypeError: Cannot read property 'body' of null

我尝试将 e.target.getContent() 放入 jQuery 的就绪函数中,但没有成功。

我正在使用 React 0.13.3。

<TinyMCE config={...} content={html} onBlur={this.handleEditorChange} />

文档的 ready() 功能无法确保 TinyMCE 已初始化并准备好进行交互。有一个 init() 函数可以添加到您的 TinyMCE 配置中,它会告诉您编辑器本身何时已初始化并准备好进行交互。您可以将代码放入您的 TinyMCE init:

tinymce.init({
    selector: '.editor',
    ....
    setup: function (editor) {
      editor.on('init', function () {
         this.setContent('Using the on init stuff!');
    });
});