1

我从我的 API 中得到一个 Html 字符串:"consigne": "<p>test</p>\n"我想在我的编辑器上显示它。

我的编辑器是:

<Editor id="consigne" name= "consigne" editorState={consigne} value={draftToHtml(convertToRaw(consigne.getCurrentContent()))} onEditorStateChange={(consigne) => {this.setState({consigne})} localization={{ locale: 'fr' }}/>

我想在我的编辑器上插入这个收货人。

我怎样才能把这个收货人推给我的编辑?

4

2 回答 2

1

我通过这个找到它:

  this.setState({ 
consigne:EditorState.createWithContent(ContentState.createFromBlockArray(convertFromHTML(plan.consigne))) 
    })
于 2019-11-08T13:49:42.833 回答
0

对于最新版本:

const blocks = convertFromHTML(plan.consigne);
this.setState({ 
  consigne: EditorState.createWithContent(ContentState.createFromBlockArray(blocks.contentBlocks, blocks.entityMap)) 
})
于 2021-09-16T23:04:22.527 回答