This article example shares the specific code of vue-pdf to realize online preview of files for your reference. The specific content is as follows Tip: Record the usage of vue-pdf to avoid forgetting and facilitate later use PrefaceTip: The following is the main content of this article. The following cases can be used for reference 1. Installationnpm install --save vue-pdf 2. PDF page display1.html <template> <div class="pdf-box"> //pdf display<pdf class="pdf" :page="pageNum" :src="pdfForm.url" @progress="loadedRatio = $event" @num-pages="pageTotalNum = $event" ></pdf> //Page number switching <div class="page-box"> <el-button-group> <el-button type="primary" icon="el-icon-arrow-left" size="mini" @click="prePage" >Previous page</el-button > <el-button type="primary" size="mini" @click="nextPage" >Next page<i class="el-icon-arrow-right el-icon--right"></i ></el-button> </el-button-group> //Page number display <div style=" color: #409EFF; display: flex; justify-content: flex-end;"> {{ pageNum }} / {{ pageTotalNum }} </div> </div> </div> </template> 2.javascript <script> import pdf from 'vue-pdf' export default { name: 'pdf', components: { pdf }, data () { pdfForm: { url: '' }, // View pdf url:'', pageNum: 1, pageTotalNum: 1, // Total number of pages loadedRatio: 0 // Loading progress of the current page, the range is 0-1, when it is equal to 1, it means that the current page has been fully loaded}, method:{ //Previous page prePage () { let page = this.pageNum page = page > 1 ? page - 1 : this.pageTotalNum this.pageNum = page }, // Next page nextPage () { let page = this.pageNum page = page < this.pageTotalNum ? page + 1 : 1 this.pageNum = page }, } } </script> Rendering SummarizeRecord the usage of vue-pdf to avoid forgetting it and to facilitate future use The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM. You may also be interested in:
|
<<: mysql8.0 forgotten password modification and net command service name invalid problem
>>: Linux nohup command principle and example analysis
This article shares with you a book flipping effe...
This article example shares the specific code of ...
Search Mirror docker search rocketmq View image v...
This time I will talk about the skills of develop...
The project requirements are: select date and tim...
1. Why does nginx use gzip? 1. The role of compre...
The excellence of Linux lies in its multi-user, m...
Table of contents Partitioning mechanism SELECT q...
Table of contents 1. Some concepts of Tomcat –1, ...
I have just started using react to do projects, a...
1. Prerequisites 1. The project has been deployed...
Vue bus mechanism (bus) In addition to using vuex...
Table of contents 1. Installation 2.APi 3. react-...
1. Installation version details Server: MariaDB S...
The command to delete images in docker is docker ...