使用ipcRenderer时,电子Js Modal无法打开

时间:2020-03-16 08:20:42

标签: javascript html electron

我正试图从充满输入框的模式中获取信息。但是,我无法测试模式输入信息的收集是否还能正常工作,因为添加ipc代码时,模式不会打开。当我删除ipc代码时,我的模式就会打开。

html

<script>    

// Modal

        document.getElementById('addItem').addEventListener('click', function(){
            document.querySelector(".bg-modal").style.display = "flex";
         });

        document.querySelector('.closeBtn').addEventListener('click', function(){
            document.querySelector(".bg-modal").style.display = "none";
        });

        // Add Information Event
        const electron = require('electron');
        const {ipcRenderer} = require('electron'); 

        const form = document.querySelector('form');
        form.addEventListener('submit', submitForm);

        function submitForm(e){
            e.preventDefault();
            const platformName = document.querySelector('#platformFor').value;
            const email = document.querySelector('#usernameForm').value;
            const starword = document.querySelector('#passwordFor').value;
            //ipcRenderer.send('information', platformName, email, starword);

            const container = document.querySelector('.informationContainer');
            const section = document.createElement('div');
            const item = document.createTextNode(platformName);

            container.appendChild(item);
        }

        /*const {ipcRenderer} = electron;
        const container = document.querySelector('.informationContainer');

        ipcRenderer.on('information', function(e, platformName){

        });*/

    </script>

js

ipcMain.on('information', function(e, platformName, email, starword){
      win.webContents.send('information', platformName);
  })

0 个答案:

没有答案