错误`未捕获的TypeError:t.addEventListener不是函数`将reactEditorSDK集成在react-dom.js中

时间:2018-03-14 14:12:48

标签: photoeditorsdk

在第一次尝试将PhotoEditorSDK集成到角度应用程序中时,我在控制台中看到了这个错误。

我的配置是:

const container = document.getElementById('editor');
const editor = new $window.PhotoEditorSDK.UI.DesktopUI({
    container: container,
    license: '{ .. }',
    assets: {
        baseUrl: '/js/pesdk/assets' // <-- This should be the absolute path to your `assets` directory
    },
    editor: {
        image: 'https://www.photoeditorsdk.com/assets/images/new/landingpage/platform_html5-4c8765e5.png',
    },
    style: {
        width: 500,
        height: 500,
    },
});

编辑器开始加载,许可证调用成功完成,然后我看到:

react-dom.production.min.js:162 TypeError: t.addEventListener is not a function
    at e._loadSource (PhotoEditorSDK.js:6)
    at new e (PhotoEditorSDK.js:6)
    at e.setImage (PhotoEditorSDK.js:73)
    at e._setImage (PhotoEditorSDK.UI.DesktopUI.js:14)
    at c (PhotoEditorSDK.UI.DesktopUI.js:14)
    at e.setImage (PhotoEditorSDK.UI.DesktopUI.js:14)
    at e.componentDidMount (PhotoEditorSDK.UI.DesktopUI.js:27)
    at commitLifeCycles (react-dom.production.min.js:148)
    at b (react-dom.production.min.js:156)
    at t (react-dom.production.min.js:167)

非缩小&#34;发展&#34; react-dom文件看起来也很简化,所以调试很麻烦。

1 个答案:

答案 0 :(得分:0)

现在image选项必须是实际的图像对象,而不是字符串URL,这是错误的来源。所以你需要先加载图像,传递它作为一个选项并加载编辑器。

如果您想结帐,有一个角度演示项目:

https://github.com/imgly/pesdk-angular-demo