// electron可以直接获取地址
e.target.files[0].path
详细:
uploadFile = () => {
this.referenceUpload.current.dispatchEvent(new MouseEvent("click"));
};
getUpload = (e) => {
console.log(e.target.value);
let file = e.target.files[0];
console.log(file.path);
this.setState({
modelPath:
window.navigator.userAgent.indexOf("Electron") !== -1
? file.path
: e.target.value,
});
};
<div
className={styles.add_algorithm_modal_body_upload_btn}
onClick={this.uploadFile}
>
选择文件
</div>
<input
type="file"
ref={this.referenceUpload}
onChange={this.getUpload}
/>
2705

被折叠的 条评论
为什么被折叠?



