我从基本 UI 集成了文件上传器,并尝试使用 React-pdf 包显示上传的文件。我尝试将文件转换为 Blob,然后使用以下代码上传它
const test = new Blob([file], { type: "application/pdf" });
const fileURL = URL.createObjectURL(test);
Run Code Online (Sandbox Code Playgroud)
相反,我尝试直接将上传的文件分配给 Document 标签,但获取该 file 属性是接受字符串而不是接收文件类型。
我也尝试使用文件阅读器,但无法实现
以下是我的代码沙箱链接:- https://codesandbox.io/s/base-web-file-uploader-basic-usage-forked-z8zpkr?file=/src/example.js:1712-1820
谁能帮我解决这个问题
我注意到的另一件事是 onLoadError 属性中出现以下错误
Error: Setting up fake worker failed: "Cannot read properties of undefined (reading 'WorkerMessageHandler'
Run Code Online (Sandbox Code Playgroud)