simiditor 在react下使用 webpack编译出现报错

clipboard.png

clipboard.png

我使用如下代码引入simiditor:

import React from 'react'
import Simditor from 'simditor'
import $ from 'jquery'
import '../../../node_modules/simditor/styles/simditor.css'
import '../../../node_modules/simditor-html/styles/simditor-html.css'

require('../../../node_modules/simditor-html/lib/simditor-html.js')

class Editor extends React.Component {
  static defaultProps = {}

  constructor(props, context) {
    super(props, context)
    this.state = {}
  }

  componentDidMount() {
    let id = 'content_' + this.props.type
    var textbox = ReactDOM.findDOMNode(this.refs[id])
    this.editor = new Simditor({
      textarea: $(textbox),
      toolbar: [
        'title',
        'bold',
        'italic',
        'underline',
        'strikethrough',
        'fontScale',
        'color',
        'ol',
        'ul',
        'blockquote',
        'code',
        'table',
        'link',
        'image',
        'indent',
        'outdent',
        'alignment',
        'hr',
        '|',
        'html'
      ],
      upload: {
        url: URLS.image_upload_url, //文件上传的接口地址
        params: null, //键值对,指定文件上传接口的额外参数,上传的时候随文件一起提交
        fileKey: 'file', //服务器端获取文件数据的参数名
        connectionCount: 3,
        leaveConfirm: '正在上传文件'
      },
    })
    this.editor.on('valuechanged', (e, src) => {
      // todo
    })
  }

  render() {
    let title = this.props.title
    let id = 'content_' + this.props.type
    let val = this.props.val
    return (
      <div>
        <div style={{
          marignTop: 10,
          marginBottom: 10
        }}>
          <Button onClick={this.handleSubmit} htmlType="button" type="danger">保存『{title}』内容</Button>
        </div>
        <textarea className="form-control" ref={id} rows="30">{val}</textarea>
      </div>
    )
  }
}

export default connect(({ loading }) => ({ loading }))(Editor)

clipboard.png

simditor的版本,不知道遗漏了什么东西

阅读 2.2k
1 个回答

重新安装一下history试试。
再看看simditorhistory版本的关系。

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题