如何在drafjs中将Json分配给Editor?

我正在获取要将对象分配给draftjs编辑器的json对象 但是当我尝试分配它时会抛出错误

“ PageContainer.js:165未捕获的TypeError:draft_js__WEBPACK_IMPORTED_MODULE_1 __。EditorState.createFromText不是函数”

this.setState({
            editorState2: EditorState.createFromText(ContentState.createFromText("hi"))
         });

编辑器已使用

从构造函数创建
 constructor(props) {
        super(props);
        this.state = {
            editorState1: EditorState.createEmpty(),editorState2: EditorState.createEmpty(),persons: []

        };
    }
lilyweiwei 回答:如何在drafjs中将Json分配给Editor?

EditorState.createFromText 更改为 EditorState.createWithContent

this.setState({
    editorState2: EditorState.createWithContent(ContentState.createFromText("hi"))
});
本文链接:https://www.f2er.com/3128318.html

大家都在问