PhoneGap - onProgress - Target null?
PhoneGap - onProgress - Target null?
我使用PhoneGap(Cordova)文件传输和onProgress函数向用户显示下载进度。
到目前为止,它运行得很好,但我正在尝试同时进行几次下载,并且我需要在onProgress事件中有一个有效的"target"属性,但它总是显示为null。
为什么?它有没有办法显示目标,比如它提供信息的文件名?
var ft0 = new FileTransfer();
ft0.onprogress = onProgress;
ft0.download( url, filePath, onDownloadSuccess, onDownloadError );
function onProgress(progressEvent) {
....
以下是onProgress事件的属性读数
type: undefined;
bubbles: false;
cancelBubble: false;
cancelable: false;
lengthComputable: true;
loaded: 5510;
total: 56456;
target: null;
任何帮助都将不胜感激。
谢谢。
您可以将下载操作封装在一个闭包中,并可以访问文件名,类似于以下内容:
filePaths.each(function(filePath) {
var ft = new FileTransfer();
ft.onprogress = function(progressEvent) {
//onProgress for filePath
};
button.addEventListener("click", function() {
ft.abort();
}, false);
ft.download( url, filePath, onDownloadSuccess, onDownloadError );
});
相关文章:
- 数组在递归方法中设置为null
- 字符串在将其传递给另一个活动Android JavaScript时读取Null
- 无法获取属性'selectedIndex'的未定义引用或null引用
- Meteor方法在客户端返回null,在客户端运行的相同方法返回正确的值
- 来自文本输入null的html javascript变量
- delete在Object上效率低下,但在DOM Element's的数据属性,与null out相比
- php代码在textbox更改事件上显示null
- 相同的RegExp返回不同的结果-第一次是正确的结果,第二次是null
- 在php中提交数据时,如果某些值为null,而某些值为非null,如何进行查询
- 未捕获的类型错误:无法读取属性'addEventListener'的null chrome扩展名
- 为什么localStorage[“..”]未定义,而localStorage.getItem(“..”)为null
- ajax在输入等于null时进行检查
- html+javascript:如何在某些条件下禁用dropdownlist中的null选项
- 未捕获的类型错误:无法读取属性'状态'在react中为null
- contentWindow.document.body is null
- 在经过DATE验证的列中创建null值
- 为什么是文档.旧版应用程序中的DOM-object.properties为null
- if(foo!==null)的计算结果为true,即使foo为null
- php函数的ajax html$_POST值返回null
- PhoneGap - onProgress - Target null?