这是我的代码我试图查看pdf文件内的Reactpdf,但无法做到这一点,因为它无法加载文件不知道为什么我已经尝试了所有的cdn提到这是网站https://cdnjs.com/libraries/pdf.js/2.7.570 其中一个还在装货https://cdnjs.cloudflare.com/ajax/libs/pdf.js/2.7.570/pdf.min.js 另一个一直给我错误或cors假冒工人失败错误需要帮助提前感谢
import { Document, Page, pdfjs } from "react-pdf";
pdfjs.GlobalWorkerOptions.workerSrc =
"https://cdnjs.cloudflare.com/ajax/libs/pdf.js/2.7.570/pdf_viewer.js.map";
const DocsViewer = ({ link }) => {
const [pages, setPages] = useState(null);
const [pageNumber, setPageNumber] = useState(1);
function onDocumentLoadSuccess({ numPages }) {
console.log("object:", numPages, pages);
setPages(numPages);
setPageNumber(1);
}
return (
<div className="property-overview-container property-flex-half">
<div className="description-overview">
<Document
file={
"https://yahuda.s3.us-east-2.amazonaws.com/4d0970da-f0c7-4a37-9ce4-5c48619a996b.pdf"
}
// link={link}
onLoadSuccess={onDocumentLoadSuccess}
onLoadError={(error) => console.log("Inside Error", error)}
>
<Page pageNumber={pageNumber} style={{ display: "none" }} />
</Document>
</div>
</div>
);
};
export default DocsViewer;
暂无答案!
目前还没有任何答案,快来回答吧!