鍍金池/ 問答/HTML/ simiditor 在react下使用 webpack編譯出現(xiàn)報(bào)錯

simiditor 在react下使用 webpack編譯出現(xiàn)報(bào)錯

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, //鍵值對,指定文件上傳接口的額外參數(shù),上傳的時(shí)候隨文件一起提交
        fileKey: 'file', //服務(wù)器端獲取文件數(shù)據(jù)的參數(shù)名
        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}』內(nèi)容</Button>
        </div>
        <textarea className="form-control" ref={id} rows="30">{val}</textarea>
      </div>
    )
  }
}

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

clipboard.png

simditor的版本,不知道遺漏了什么東西

回答
編輯回答
生性

重新安裝一下history試試。
再看看simditorhistory版本的關(guān)系。

2018年3月4日 11:05