当我保存表单(onSubmit)时,我收到此错误:您正在将事件中的delta对象传onChange回value.你很可能想要的editor.getContents().
脚本的其余部分运行正常,并按预期将所有内容写入数据库,但React-Quill触发错误并挂起页面.
我需要做什么来定义editor.getContents()?
export default class CreateDiscussionForm extends Component {
constructor(props){
super(props);
this.state = {
error: '',
editorHtml: ''
};
this.handleChange = this.handleChange.bind(this);
}
handleChange (html) {
this.setState({ editorHtml: html });
}
onSubmit(e) {
var background = this.state.editorHtml;
console.log('background', background); //<p>testing</p>
//... rest of code
<ReactQuill
name="editor"
theme={'snow'}
ref="comment"
onChange={this.handleChange}
value={this.state.editorHtml}
modules={quillModules}
placeholder="add the discussion background (optional)"
/>
Run Code Online (Sandbox Code Playgroud)
提前谢谢 - 鲍勃
may*_*yid 19
不确定为什么Quill将初始值解释为delta根,但我通过传递一个如下所示的空字符串来解决此警告:
<ReactQuill
name="editor"
onChange={this.handleChange}
value={this.state.editorHtml || ''}
/>
Run Code Online (Sandbox Code Playgroud)
错误链接到这里btw:https://github.com/zenoamaro/react-quill#using-deltas 这是对Quill解释为增量的更高级描述:https://quilljs.com/docs/delta/ (基本上,增量是以json格式存储的更改,它们与quill分开处理,这意味着它是一个外部库)
| 归档时间: |
|
| 查看次数: |
3714 次 |
| 最近记录: |