tags: React
npm install react-file-viewer
// This component is introduced
import FileViewer from 'react-file-viewer';
render() {
let { top, file } = this.state;
let { play, sonstate } = this.props
var index = file.lastIndexOf(".");
var type = file.substr(index + 1);
return (
<div>
<div className="top" style={{ display: play ? 'flex' : 'none' }}>
<div className="all" >
<div className="allname">
<div className="topall"><Button style={{ opacity: '0' }}>shut down</Button><div></div><Button onClick={() => {
sonstate(false)
this.setState({ top: false, file: '' })
}}>shut down</Button>
</div>
{/ * Use of this component * /}
<FileViewer fileType={type}
filePath={file}
onError={this.onError}
errorComponent={Error}
unsupportedComponent={Error}
/>
</div>
</div>
</div>
</div>
)
}
Note that this module is most suitable for 16+ reaction. If you are using React <16, you may need to use the 0.5 version. npm install [email protected].
There is a major component of React FileViewer, which uses the following items:
fileTypestring: resource type to be displayed (for example, one file format support 'png'). Incoming unsupported file types will result in displays unsupported file type messages (or custom components).
filePath string: url resources FileViewer displayed.
onErrorfunction [Optional]: Gets or rendering function that will be called when an error occurs when the requested resource in the file viewer. You can pass callback logging utility here.
errorComponent react element [Optional]: Component presented when an error occurs, rather than the default error component and react-file-viewer packaged together.
unsupportedComponent react element [Optional]: Components presented in the case do not support the file format.
ps: of course, you can look at this linkhttps://www.npmjs.com/package/react-file-viewer
Java implementation Word Transfer PDF online preview format This function involved in the project, survived some programs, stepped on some pits, and summarized here. Java turns a lot of solutions, but...
Implementation After finding the online implementation plan, the effect looks good. Put it in the table below. Some of them can be introduced directly in the Vue through the NPM. Document format Old o...
Idea: This online preview is encountered in the project. Most of the solutions are Word Transfer PDF and then call PDFJS to complete page preview. 1. Introducing POM dependence The code! contro...
file-preview Online preview of word, excel, ppt, and pdf files.View Technology used Nuxt.js express element-ui typeorm pdf.js Online preview of word, excel, pptMicrosoft interface documentation node-s...
Demand project: the background upload some doc or pdf and other documents required front-end for online preview these files. Ideas: the interface will return to a path, combining <embed /> tag, ...
Recently, I am working on a shared digital platform, and record some of the functional knowledge involved. , Other tutorials are written too old, and may no longer be applicable today. 1. JSP realizes...
Solution: 1. Use the conversion function provided by AsposeCells and AsposeWords related Jar packages to convert Excel and Word type documents into Pdf files and store them in the current project dire...
Recently, a need is to preview various files online. If you find a fee, you will be connected to the external network. Finally, I found an open source project when I wandered myself. The specific proc...
Django implements online preview PDF, Word, XLS, PPT and other files 1. Add files to static resources 2, configure view functions views.py 3、html<object type="application/pdf" data='../.....