methods: {
isSave (ev) {
this.localFileUrl = ev.localFileUrl // 本地的路径
ipcRenderer.send('save-dialog', ev.localFileUrl)
ipcRenderer.on('saveFile', (event, path1) => {
if (!path1) path1 = '无路径'
console.log(path1) // 打印很多次,不会关
// this.copyFile(ev.localFileUrl, path1)
// fs.createReadStream(ev.localFileUrl).pipe(fs.createWriteStream(path1))
})
}
}
自己解决的方式,在created中监听就不会有这个问题
created () {
ipcRenderer.on('saveFile', (event, path1) => {
if (!path1) path1 = '无路径'
console.log(path1)
// this.copyFile(ev.localFileUrl, path1)
// fs.createReadStream(ev.localFileUrl).pipe(fs.createWriteStream(path1))
})
},