import React, { Component } from 'react'; import logo from './logo.svg'; import './App.css'; import E from 'wangeditor' class App extends Component { constructor(props, context) { super(props, context); this.state = { editorContent: '' } } render() { return (
logo

Welcome to React

To get started, edit src/App.js and save to reload.

{/* 将生成编辑器 */}
); } componentDidMount() { const elem = this.refs.editorElem const editor = new E(elem) // 使用 onchange 函数监听内容的变化,并实时更新到 state 中 editor.customConfig.onchange = html => { this.setState({ editorContent: html }) } editor.create() } clickHandle() { alert(this.state.editorContent) } } export default App;