当前位置:网站首页>[uniapp] uniapp development app online Preview PDF file
[uniapp] uniapp development app online Preview PDF file
2022-07-04 19:02:00 【A dying salted fish】
1. You need to download a copy from the Internet pdf.js
Put your files into your own project
2. except pdf.html
file , Other files can be created pdf
Folder , Put it under this directory , And then pdf
Put the folder in the project static
Under the table of contents ,pdf.html
Also put it separately static
Under the table of contents , Finally, as shown in the figure below :
3. To achieve pdf preview , Need to use uniapp
Of apiweb-view
, Create a new one .vue
file , Write the following code :
<template>
<view class="webView">
<cu-custom isBack top :bgColor="NavBarColor">
<block slot="content"> The online preview </block>
</cu-custom>
<web-view :src="urls"></web-view>
</view>
</template>
<script> export default {
data() {
return {
NavBarColor: this.NavBarColor, urls: '', } }, onLoad(params) {
let {
url: urls} = params // /static/pdf.html Just put it on static In the catalog pdf.html file location this.urls = `/static/pdf.html?url=${
urls}` } } </script>
4. Click on a pdf file , Jump to the newly created web-view
In file , And need to carry url Parameter jump ,pdf.js
Will be based on url The data obtained by the parameters after , Generate pdf And render to the page , As shown below :
seeVideo(item) {
if (item.subjectType === ' file ') {
// pdf File preview
uni.navigateTo({
// this.$config.staticDomainURL It's a preview pdf An interface to the file
// item.videos Get is pdf Path to file
url: '/pages/shop/webView?url=' + this.$config.staticDomainURL + '/' + item.videos
})
} else {
// ......
}
}
边栏推荐
- Detailed explanation of the maturity classification of ITSS operation and maintenance capability | one article clarifies the ITSS certificate
- NBA赛事直播超清画质背后:阿里云视频云「窄带高清2.0」技术深度解读
- Wireshark packet capturing TLS protocol bar displays version inconsistency
- 字节跳动Dev Better技术沙龙成功举办,携手华泰分享Web研发效能提升经验
- fopen、fread、fwrite、fseek 的文件处理示例
- 力扣刷题日记/day1/2022.6.23
- VMware Tools和open-vm-tools的安装与使用:解决虚拟机不全屏和无法传输文件的问题
- Learning path PHP -- phpstudy "hosts file does not exist or is blocked from opening" when creating the project
- How to open an account is safe,
- Basic tutorial of scala -- 16 -- generics
猜你喜欢
神经网络物联网是什么意思通俗的解释
力扣刷题日记/day5/2022.6.27
Scala基础教程--15--递归
An example of multi module collaboration based on NCF
[go language question brushing chapter] go conclusion chapter | introduction to functions, structures, interfaces, and errors
Scala basic tutorial -- 17 -- Collection
Rookie post station management system based on C language
力扣刷題日記/day6/6.28
力扣刷题日记/day2/2022.6.24
VMware Tools和open-vm-tools的安装与使用:解决虚拟机不全屏和无法传输文件的问题
随机推荐
Nature Microbiology | 可感染阿斯加德古菌的六种深海沉积物中的病毒基因组
[go ~ 0 to 1] read, write and create files on the sixth day
利用策略模式优化if代码【策略模式】
repeat_P1002 [NOIP2002 普及组] 过河卒_dp
力扣刷题日记/day4/6.26
Process of manually encrypt the mass-producing firmware and programming ESP devices
Halcon模板匹配
力扣刷题日记/day2/2022.6.24
.NET ORM框架HiSql实战-第二章-使用Hisql实现菜单管理(增删改查)
未来几年中,软件测试的几大趋势是什么?
奥迪AUDI EDI INVOIC发票报文详解
2022-07-04: what is the output of the following go language code? A:true; B:false; C: Compilation error. package main import 'fmt' func
完善的js事件委托
Rookie post station management system based on C language
力扣刷題日記/day6/6.28
神经网络物联网应用技术学什么
How to modify icons in VBS or VBE
【uniapp】uniapp开发app在线预览pdf文件
删除二叉搜索树中的节点附图详解
Li Chi's work and life summary in June 2022