0

目前使用 photoeditorsdk@4.3.1

使用纯 JS 示例,导出图像就可以了。

window.onload = () => {

  const container = document.getElementById('app')

  const editor = new PhotoEditorSDK.UI.ReactUI({
    container,
    license: JSON.stringify(PESDK_LICENSE),
    assets: {
      baseUrl:'/assets'
    },
  })

  window.editor = editor
}

当尝试将 photoeditorsdk 包装到 React 组件中时,如下所示

class Editor extends Component {
  constructor (props) {
    super(props)
  }
  componentDidMount () {
    const container = this.refs.pesdk
    const editor = new PhotoEditorSDK.UI.ReactUI({
      container,
      license: JSON.stringify(PESDK_LICENSE),
      assets: {
        baseUrl: '/assets'
      },
      title: 'Photo Editor'
    })

    window.editor = editor
  }

  render () {
    return (
      <div ref='pesdk'></div>
    )
  }
}

export default Editor

并使用导出图像

editor.export(false).then(image => document.body.append(image)) 

fromwindow.editor会遇到错误

react-dom.development.js:5622 Uncaught TypeError: Cannot read property 'export' of null
    at t.export (react-dom.development.js:5622)
    at <anonymous>:1:14
4

1 回答 1

0

我无法在这里重现这一点。你能提供更多细节吗?例如,您在何时何地打电话editor.export。另外,您是否将图像作为选项传递给编辑器?

于 2018-03-23T13:22:46.333 回答