如何在 drafjs 中将 Json 分配给编辑器?
How do I assign Json to Editor in drafjs?
我得到 json 对象,我想在其中将文本分配给 draftjs 编辑器
但是当我尝试分配它时它会抛出错误
"PageContainer.js:165 Uncaught TypeError: draft_js__WEBPACK_IMPORTED_MODULE_1__.EditorState.createFromText is not a function"
this.setState({
editorState2: EditorState.createFromText(ContentState.createFromText("hi"))
});
编辑器已经通过
的构造函数创建
constructor(props) {
super(props);
this.state = {
editorState1: EditorState.createEmpty(),
editorState2: EditorState.createEmpty(),
persons: []
};
}
将EditorState.createFromText更改为EditorState.createWithContent
this.setState({
editorState2: EditorState.createWithContent(ContentState.createFromText("hi"))
});
我得到 json 对象,我想在其中将文本分配给 draftjs 编辑器 但是当我尝试分配它时它会抛出错误
"PageContainer.js:165 Uncaught TypeError: draft_js__WEBPACK_IMPORTED_MODULE_1__.EditorState.createFromText is not a function"
this.setState({
editorState2: EditorState.createFromText(ContentState.createFromText("hi"))
});
编辑器已经通过
的构造函数创建 constructor(props) {
super(props);
this.state = {
editorState1: EditorState.createEmpty(),
editorState2: EditorState.createEmpty(),
persons: []
};
}
将EditorState.createFromText更改为EditorState.createWithContent
this.setState({
editorState2: EditorState.createWithContent(ContentState.createFromText("hi"))
});