您好,我使用的追随代码无法正常工作。如何重设密码。
fileTransfer.download(url, path + 'abcd.pdf').then((entry) => {
let localUrl = entry.toURL();
const toast = this.toast.create({
message: 'Download Complted',
duration: 20000,
position: 'top',
closeButtonText: 'OK',
showCloseButton: true,
});
toast.present();
this.document.viewDocument(localUrl, 'application/pdf', {});
}, (error) => {
// handle error
console.log("In error");
console.log(error);
alert(JSON.stringify(error));
});
如何工作!
答案 0 :(得分:1)
您是否在项目中添加了文档查看器插件?请查看此链接https://ionicframework.com/docs/native/document-viewer/,您可以找到命令。
ionic cordova plugin add cordova-plugin-document-viewer
npm install --save @ionic-native/document-viewer
然后,您还必须在viewDocument函数中传递选项
fileTransfer.download(url, path + 'abcd.pdf').then((entry) => {
let localUrl = entry.toURL();
const toast = this.toast.create({
message: 'Download Complted',
duration: 20000,
position: 'top',
closeButtonText: 'OK',
showCloseButton: true,
});
toast.present();
const options: DocumentViewerOptions = {
title: 'My PDF'
}
this.document.viewDocument(localUrl, 'application/pdf', options);
}, (error) => {
// handle error
console.log("In error");
console.log(error);
alert(JSON.stringify(error));
});
希望这对您有用!