index.tsx
657 Bytes
import { useEffect, useState } from 'react';
import './index.less';
interface pdfPreviewProps {
url?: string
}
const pdfPreview = (props: pdfPreviewProps) => {
const [filePath, setFilePath] = useState<string>();
useEffect(()=>{
if (props.url) {
const _url = encodeURIComponent(props.url);
setFilePath(_url);
}
},[props.url])
return (
<div className={'pdfPreview'}>
<iframe
title="pdf-preview"
style={{ width: '100%', height: '100%' }}
src={`https://h5jianke.21tb.com/file/generic_mobile/web/viewer.html?file=${filePath}`}
/>
</div>
);
};
export default pdfPreview;