当我尝试使用带有 reactJS 的 Uppy 控件上传文件时,我遇到了一些问题。
我第一次上传文件时它消失了。如果状态不保持,那么它的工作正常。但如果文件类型是“.xlsx”或“.pdf”,我需要设置状态
请建议。
下面是 .js 文件。
import React from "react";
import { Dashboard } from "@uppy/react";
import "@uppy/core/dist/style.css";
import "@uppy/dashboard/dist/style.css";
const Uppy = require("@uppy/core");
const UppyDashboard = require("@uppy/dashboard");
const UppyComp = props => {
const [IsPerso, setIsPerso] = React.useState(true);
const uppy = Uppy({
debug: true,
autoProceed: false,
restrictions: {
maxFileSize: "2621440",
maxNumberOfFiles: null,
minNumberOfFiles: null,
allowedFileTypes: [".pdf", ".xlsx"]
},
onBeforeFileAdded: (currentFile, files) => {
setIsPerso(false);
alert(IsPerso);
}
}).use(UppyDashboard, {
inline: false,
hideUploadButton: true,
showProgressDetails: true,
note: "Images and video only, 2–3 files, up to 1 MB",
height: 470,
browserBackButtonClose: true
});
return (
<div>
<div>
<br />
<Dashboard uppy={uppy} />
<br />
</div>
</div>
);
};
export default UppyComp;