首页 > 编程知识 正文

vue本地pdf预览,2021张宇基础30讲pdf

时间:2023-05-05 02:21:56 阅读:40683 作者:468

vue安装vue-pdf(pdf预览) # NPM NPM安装--save vue-pdf #页面浏览//pdf预览导入pdf from ' vue-pdf '; 第#页为Home.vue

src/views/Home.vue

templatedivclass=' main ' div buttontype=' button ' @ click=' changepdfpage (0)上一页/button buttontype=' button @ type='button'@click='scaled ()放大/buttonbuttontype='buttontype ) ) button ) button 652 divdivbuttonty button buttontype=' button ' @ click=' counter clock ) '逆时针/button'@click ) )逆时针divpdfref=' pdf ' : src=' src ' : page=' current page ' 3360 rotate=' page rotate ' @ num div/templatescript//pdf预览导入pdf from ' vue-pdf '; 导出默认值{ name : ' home,components: { pdf }, 数据() return ) src : ' http://storage.xuetangx.com/public _ assets/xuetangx/pdf/playerapi _ v1.0.6. PPP 、methods: { //pdf加载时loadpdfhandler(e ); this.currentPage=1; //加载时先加载第一页},如果更改//pdf的页码,则从val开始上一页的下一页的值、0上一页、第一页的changepdfpage(val )、if (val==0thithid },//放大scaleD () { this.scale =5; this.$ refs.pdf.$ El.style.width=parseint (this.scale ) ' % ';scaleX () if ) this.scale===100 ) ) { return; } this.scale =-5; this.$ refs.pdf.$ El.style.width=parseint (this.scale ) ' % ';//顺时针clock () { this.pageRotate =90;//逆时针旋转counterClock () { this.pageRotate -=90; }; };/scriptstylescoped.main { width :500 px; margin : 0自动; border : 2px固态# 409 eff; padding: 10px; }/style默认情况下显示第一页

更多请看文档:https://www.npmjs.com/package/vue-pdf

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。