效果:

这里要借助vue-pdf插件去展示缩略图:
安装方法
npm install --save vue-pdf
html片段:
<div class="wrap">
<input type="file" @change="fileChange" multiple />
<div
v-for="(item, index) of pdf"
:key="index"
@click="showPdf(item)"
style="width:102px;height:102px;background:#fff;display:flex; justify-content: center;"
>
<pdf :src="item" style="width:70px;height:102px;"></pdf>
</div>
</div>
js:
import pdf from "vue-pdf";
export default {
components: {
pdf
},
本文介绍了如何使用Vue结合vue-pdf插件实现PDF文件的上传,并展示缩略图,同时提供了预览功能,包括页面切换。安装vue-pdf插件后,在HTML中插入组件,并在JavaScript中处理PDF预览和分页操作。
订阅专栏 解锁全文
1万+





