我在开发模式(ionic cordova run android
)中使用filetransfer.download非常好。但是当我想在生产模式(ionic cordova run android --prod
)中使用它时,我什么都看不到。实际上,没有调用入口和错误。我的代码:
this.fileTransfer.download(encodeURI(url), <file-path> , false , some header ).then((entry) => {
this.messageCtrlService.showAlert(JSON.stringify(entry.toURL()), 'Success');
}, (error) => {
this.messageCtrlService.showAlert(JSON.stringify(error), 'Error');
});
编辑:当我使用此命令构建应用程序时:
ionic cordova --minifycss --aot --optimizejs --release
一切都好。无论如何要防止一些插件(如文件传输)从minify?怎么样?
不确定这是否可以帮助任何人,但在我的情况下,缩小使代码运行得更快,因此我的一个提供者在this.fileTransfer = this.transfer.create();
事件被触发之前执行devideready
。
我修复了以下内容:
constructor(private transfer: FileTransfer,
private platform: Platform,
private other: Other) {
this.platform.ready().then(() => {
this.fileTransfer = this.transfer.create();
});
}