电子版:1.3.3操作系统:乌班图14.04
我想用 Electron 将 XML 对象保存到 .xml 文件中。我试试这个:
const {dialog} = require("electron").remote;
dialog.showSaveDialog(myObj)
A new windows is opening, I fill the name of the file but nothing has been saving.
![enter image description here](https://i.stack.imgur.com/4dpdd.png)
建议使用dialog.showSaveDialog返回的路径来获取filepath
在新版本的电子中:(即result.filePath
在下面的代码中)
filename = dialog.showSaveDialog({}
).then(result => {
filename = result.filePath;
if (filename === undefined) {
alert('the user clicked the btn but didn\'t created a file');
return;
}
fs.writeFile(filename, content, (err) => {
if (err) {
alert('an error ocurred with file creation ' + err.message);
return
}
alert('WE CREATED YOUR FILE SUCCESFULLY');
})
alert('we End');
}).catch(err => {
alert(err)
})
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)