从后端查询出的http路径使用实现在线查看
官方文档 https://www.npmjs.com/package/react-pdf
安装
npm install react-pdf
引入
import { Document, Page } from 'react-pdf';
import { pdfjs } from 'react-pdf';
pdfjs.GlobalWorkerOptions.workerSrc = `//cdnjs.cloudflare.com/ajax/libs/pdf.js/${pdfjs.version}/pdf.worker.js`;
正文
import React, {useEffect, useState} from "react";
import { Document, Page } from 'react-pdf';
import Pagination from "antd/es/pagination";
import { pdfjs } from 'react-pdf';
pdfjs.GlobalWorkerOptions.workerSrc = `//cdnjs.cloudflare.com/ajax/libs/pdf.js/${pdfjs.version}/pdf.worker.js`;
const PDFViewer = (props) => {
const {alreadySrc} = props; //父组件传来的路径
const [page, setPage] = useStat