如何解决电容器 writefile() 不适用于移动设备
先生,我在 android 上下载 pdf 文件时遇到问题,下载正在网络上运行,但是当我在设备上安装应用程序时,按下下载按钮没有任何反应。
这是我创建pdf的代码
createPdf(){
var docDefination ={
content:[
//defining the header of the pdf
{text: 'YourTask',style:'header'},{text: new Date().toTimeString(),alignment:'right'},//defining the content of the pdf
{text:'Title',style: 'subheader'},{text: this.passedValue.title},{text:'value',style:'subheader'},{text: this.passedValue.value},//{text :this.passedValue.text,style:'story',margin:[0,20,20]},],styles:{
header:{
fontSize: 18,bold :true,},subheader:{
fontSize :14,bold: true,margin: [0,15,0]
},}
}
this.pdfObj =pdfMake.createPdf(docDefination);
}
这是为了在设备上下载这个
if(this.plt.is('cordova')){
this.showtoast();
this.pdfObj.getBased64(async (data)=>{
try{
let path =`pdf/myletter_${Date.now()}.pdf`;
const result = await Filesystem.writeFile({
path,data,directory: FilesystemDirectory.Data,recursive: true
});
this.fileOpener.open(`${result.uri}`,'application/pdf');
console.log(result);
} catch(e){
console.error('unable to wite file',e);
}
});
}`enter code here`
else{
this.pdfObj.download();
}
}`enter code here`
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。