//主进程 ipcMain.on('chooseMusic', (event,args) => { dialog.showOpenDialog(mainWindow, { properties: ['openFile', 'multiSelections'], filters: [{name: 'Music', extensions: ['mp3']}] }).then((files) => { if (files) { console.info("start selected-file"); event.sender.send('selected-file', files); console.info("end selected-file"); } }) }) //渲染进程 ipcRenderer.on('selected-file', () => { console.info("selected-file"); })
1、实际上渲染进程收到了消息,渲染进程的console.info再web控制台打印,
2、主进程传的files不对,路径传输应该用files.filepaths