我正在用electronic和reactjs创建一个应用程序。在该应用程序中,我想创建一个组件供用户选择文件下载路径。有可能使用react,我该如何完成这项任务?
最佳答案
您可以像下面这样轻松地进行操作:
<button type="button" onClick={this.handleSetDownloadPath}>Set Download Path</button>
handleSetDownloadPath
方法是:import { remote } from "electron";
...
handleSetDownloadPath = () => {
remote.dialog.showOpenDialog(
{
properties: ["openDirectory"]
},
files => {
if (files) {
this.setState({
downloadPath: files[0]
});
}
}
);
};
关于reactjs - Electron react 设置文件下载路径,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61579896/