Skip to content

Commit

Permalink
修复pdf报错
Browse files Browse the repository at this point in the history
  • Loading branch information
liuqinh2s committed Aug 30, 2023
1 parent 071dc0a commit 6128456
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/components/EBook/PDF.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import React, {useState} from 'react';
import { Document, Page } from 'react-pdf';
import React, { useState } from 'react';
import { Document, Page, pdfjs } from 'react-pdf';

interface IEBook {
source: string; // 资源地址
}

export const PDFPreview = (props: IEBook)=> {
const {source} = props;
pdfjs.GlobalWorkerOptions.workerSrc = `//unpkg.com/pdfjs-dist@${pdfjs.version}/build/pdf.worker.min.js`;

export const PDFPreview = (props: IEBook) => {
const { source } = props;
const [numPages, setNumPages] = useState<number>();
const [pageNumber, setPageNumber] = useState<number>(1);

Expand Down

0 comments on commit 6128456

Please sign in to comment.