worker.onMessage(res => {
console.log('子线程内接收信息',res);
console.log('IOS_worker',worker);
if (res.msg == 'start') {
globalThis.dlTest();
}
// else {
// globalThis.downloadTask.abort();
// }
});
globalThis.dlTest = () => {
const downloadTask = worker.downloadFile({
url:`https://cesu.ha.chinamobile.com/speed/200000.data?cors=true&r=${Math.random()}&ckSize=100`,
success: (res) => {
},
complete:(info) => {
console.log('下载文件回调(不区分成功失败)',info);
}
});
console.log(downloadTask);
downloadTask.onProgressUpdate(event => {
console.log('progress',event);
});
}
第二次启用worker时 下载监听就失效了