安卓在線讀取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"; //數字是頁面布局高度差 },
