安卓在线读取pdf不能直接打开,而ios可以;
是因为安卓的webView不支持导致的,
解决----引入pdf.js文件
在iframe
<div class="outer"> <iframe class="show-box" :src="\'http://uattest.tppension.cntaiping.com/static/mjcd/static/pdf/web/viewer.html?file=\'+ url" id="myiframe" scrolling="no" frameborder="0" width="100%" border="0" ></iframe> </div>
注意:百度到的src路径前面没有域名,只能在本地调试,放到测试或生产上不行,所以要加域名
created() { // // 显示loding // Indicator.open("加载中..."); this.url=encodeURIComponent(this.pdfLink) console.log(this.url); setTimeout(() => { console.log("组件里面显示pdf链接", this.pdfLink); }, 0); alert(\'/static/pdf/web/viewer.html?file=\'+ url) }, props: ["pdfLink"], data() { return { url:"" }; },
mounted() { const myiframe = document.getElementById("myiframe"); const deviceWidth = document.documentElement.clientWidth; const deviceHeight = document.documentElement.clientHeight; myiframe.style.overflow = "scroll"; // myiframe.style.width = Number(deviceWidth) + "px"; //数字是页面布局宽度差值 myiframe.style.height = Number(deviceHeight) + "px"; //数字是页面布局高度差 },