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
1. Block-level element: refers to the ability to e...
Table of contents Preface HTTP HTTP Server File S...
Currently encountering such a problem My situatio...
MySQL and connection related timeouts Preface: To...
Preface This article mainly introduces the releva...
The effect to be achieved In many cases, we will ...
Referring to other more professional blog systems...
This article records the installation and configu...
Table of contents MYSQL METADATA LOCK (MDL LOCK) ...
Why are the SQL queries you write slow? Why do th...
In the horizontal direction, you can set the cell...
Install antd-mobile Global import npm install ant...
Overview: I drew lessons from several timetable s...
FIFO communication (first in first out) FIFO name...
Table of contents 1. Introduction 2. Analysis of ...