我想下载文件并将其保存到所需的文件夹,但每次我收到以下错误。
ipcMain.on('download-file', function (event, data) {
console.log(data);
download(BrowserWindow.getFocusedWindow(), data.url, {
directory: "G:\\Orders\\"
}).then(function (dl) {
console.log(dl.getSavePath());
}).catch(console.error);
});
TypeError: Cannot read property 'webContents' of null
at Promise (G:\fc-electron\node_modules\electron-dl\index.js:125:22)
at Promise (<anonymous>)
at module.exports.download (G:\fc-electron\node_modules\electron-dl\index.js:122:47)
at EventEmitter.<anonymous> (G:\fc-electron\main.js:53:9)
at emitTwo (events.js:125:13)
at EventEmitter.emit (events.js:213:7)
at WebContents.<anonymous> (G:\fc-electron\node_modules\electron\dist\resources\electron.asar\browser\api\web-contents.js:249:13)
at emitTwo (events.js:125:13)
at WebContents.emit (events.js:213:7)
任何有用的答案都将不胜感激。