uni-app 微信小程序使用 web-view 预览PDF
生活随笔
收集整理的這篇文章主要介紹了
uni-app 微信小程序使用 web-view 预览PDF
小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
1、使用uni-pp開(kāi)發(fā)微信小程序,上線之后發(fā)現(xiàn)Android手機(jī)無(wú)法加載覽PDF,但ios可以。這里運(yùn)用了 uni.openDocument
<template><view class="wenj" @click="file" >點(diǎn)擊查看文件</view> </template><script>export default {data() {return {attach_url: '',}},onLoad(option) {},onShow() {},methods: {file(){uni.showToast({title: '加載中',duration: 5000,icon:"loading"});uni.downloadFile({url: this.attach_url, //文件名success: function (res) {var filePath = res.tempFilePath;uni.openDocument({filePath: filePath,success: function (res) {console.log('打開(kāi)文檔成功');uni.hideToast();}});}});}},} </script><style lang="scss">page {background: #F9F9F9;}.wenj{height: 100rpx;display: flex;justify-content: flex-end;align-items: center;font-size: 30rpx;color: #008AFF;} </style>這里使用了一個(gè)點(diǎn)擊事件 因?yàn)槿绻苯邮褂眉虞d會(huì)很慢,還沒(méi)加載完用戶已經(jīng)退出來(lái)
總結(jié)
以上是生活随笔為你收集整理的uni-app 微信小程序使用 web-view 预览PDF的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: uni-app实现微信小程序本地图片转为
- 下一篇: 嵌入式操作系统内核原理和开发