简体   繁体   English

Cordova文件传输插件的IONIC错误

[英]IONIC Error with Cordova file-transfer plugin

I am using the following version of IONIC and Cordova; 我正在使用以下版本的IONIC和Cordova;

IONIC; 离子;

1.5.5

Cordova; 科尔多瓦;

5.1.1

Build my mobile application. 构建我的移动应用程序 But when ever I finish building it and run it I keep getting the following exception: 但是,当我完成构建并运行它时,我不断得到以下异常:

Uncaught module cordova-plugin-file.ProgressEvent not found

Could someone please help me out ?. 有人可以帮帮我吗?

I had the same issue today and in my case this was because the version of the file-transfer plugin was not compatible with the File plugin I use. 我今天遇到了同样的问题,在我的情况下,这是因为文件传输插件的版本与我使用的File插件不兼容。

The file transfer plugin requires the cordova-plugin-file.ProgressEvent (see FileTransfer.js in the file transfer plugin directory) But if you're still using an older version of the file plugin (in my case org.apache.cordova.file instead of cordova-plugin-file) then it can't resolve that. 文件传输插件需要cordova-plugin-file.ProgressEvent(请参阅文件传输插件目录中的FileTransfer.js)但是如果您仍在使用旧版本的文件插件(在我的情况下是org.apache.cordova.file而不是cordova-plugin-file)然后它无法解决这个问题。

So either you update your plugins so you use the cordova-file-plugin or you change the code of the FileTransfer plugin, this is not advised because when the plugins are reinstalled you will loose this change. 因此,要么您更新插件以便使用cordova-file-plugin或更改FileTransfer插件的代码,建议不要这样做,因为重新安装插件时您将失去此更改。 But if for whatever reason you can't use the newer file plugin you can use this method. 但是,如果由于某种原因您无法使用较新的文件插件,您可以使用此方法。

On line 25 of the FileTransfer.js file change 在FileTransfer.js文件的第25行更改

ProgressEvent = require('cordova-plugin-file.ProgressEvent');

to

ProgressEvent = require('org.apache.cordova.file.ProgressEvent');

If that doesn't solve it, try to look up the correct module name in your File plugin directory's config.xml file (look for the ID property) and use that instead (don't forget to append ProgressEvent) 如果这不能解决问题,请尝试在File plugin目录的config.xml文件中查找正确的模块名称(查找ID属性)并改用它(不要忘记附加ProgressEvent)

To elaborate on my point of not changing the code of the FileTransfer plugin you can however copy the plugin code and put it somewhere on your disk and use that plugin instead of the hosted one (which is loaded and used if you just use the plugin's ID) 为了详细阐述我不改变FileTransfer插件代码的观点,你可以复制插件代码并将其放在磁盘上并使用该插件而不是托管插件(如果你只是使用插件的ID就加载和使用它)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM