Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/414.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript electron react应用程序多个子窗口,只能打开一个子窗口_Javascript_Reactjs_Electron - Fatal编程技术网

Javascript electron react应用程序多个子窗口,只能打开一个子窗口

Javascript electron react应用程序多个子窗口,只能打开一个子窗口,javascript,reactjs,electron,Javascript,Reactjs,Electron,我已经在react electron应用程序中打开了一个childwindow,但我想打开多个childwindow。我尝试过用道具动态命名childwindow框架名,但也不起作用 下面是子窗口类组件: export default class ChildWindow extends Component { containerEl = document.createElement('div'); styleEl = document.createElement('style'); extern

我已经在react electron应用程序中打开了一个childwindow,但我想打开多个childwindow。我尝试过用道具动态命名childwindow框架名,但也不起作用

下面是子窗口类组件:

export default class ChildWindow extends Component {
containerEl = document.createElement('div');
styleEl = document.createElement('style');
externalWindow = null;

componentDidMount() {
    this.externalWindow = window.open('', 'ChildWindow');
    
    if (this.externalWindow)
    {
        this.containerEl.style.height = '100vh';
        this.containerEl.style.width = '100vw';
        this.externalWindow.document.body.appendChild(this.containerEl);
        this.externalWindow.document.body.style.margin = '0';
        this.externalWindow.onunload = () => this.props.onClose();
    }
}

render() {
    return ReactDOM.createPortal(this.props.children, this.containerEl);
}
}
以下是electron.js文件中的新窗口代码设置:

    mainWindow.webContents.on('new-window', (event, url, frameName, disposition, options, additionalFeatures) => {
    if (frameName === 'ChildWindow') {
        event.preventDefault();
        Object.assign(options, {
            // parent: mainWindow,
            height: 700,
            width: 400,
            minHeight: 700,
            minWidth: 400,
            resizable: false,
            frame: false,
            webPreferences: {
                enableRemoteModule: true,
                nodeIntegration: true,
                webSecurity: false,
                nativeWindowOpen: true
            }
        });
        const newWindow = new BrowserWindow(options);
        event.newGuest = newWindow;
    }
});
这里还有我在函数类中使用childwindow组件的代码:

                <ChildWindow
                    onClose={closeCaptchaSolver}
                >
                    <p>hoi</p>
                </ChildWindow>