TinyMCE与ReactJs-onChange事件仅触发一次

我在我的reactjs应用程序中使用tinyMCE。onChange事件将触发一次,以在警报中正确反映输入数据。然后我什么也没得到。


以下是相关代码:


<Editor init={{

    statusbar: false,

    menubar: false,

    }}

    onChange={this.SetText}

 />

onChange方法:


SetText(e) {

    alert(e.target.getContent());

}


大话西游666
浏览 560回答 2
2回答

慕婉清6462132

实际上,您使用的事件不正确。对于reactJs插件,它们具有onEditorChange。您可以按以下方式使用它<Editor&nbsp; apiKey="MyAPIKey"&nbsp; initialValue=""&nbsp; init={{&nbsp; &nbsp; height: 500,&nbsp; &nbsp; menubar: false,&nbsp; &nbsp; plugins: [&nbsp; &nbsp; &nbsp; 'advlist autolink lists link image charmap print preview anchor',&nbsp; &nbsp; &nbsp; 'searchreplace visualblocks code fullscreen',&nbsp; &nbsp; &nbsp; 'insertdatetime media table paste code help wordcount'&nbsp; &nbsp; ],&nbsp; &nbsp; toolbar:&nbsp; &nbsp; &nbsp; 'undo redo | formatselect | bold italic backcolor | \&nbsp; &nbsp; &nbsp; alignleft aligncenter alignright alignjustify | \&nbsp; &nbsp; &nbsp; bullist numlist outdent indent | removeformat | help'&nbsp; }}&nbsp; onEditorChange={this.onChange}/>然后您可以使用来访问编辑器的内容&nbsp; onChange = (content) => {&nbsp; &nbsp; console.log(content);&nbsp; }e.target 不需要
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

JavaScript