data: {
progress: 0
},
download: function () {
let downloadTask = wx.downloadFile({
url: ‘test.php’,
success: res => {}
});
downloadTask.onProgressUpdate(res => {
this.setData({progress:res.progress});
});
}
}
<progress class="progress" percent="{{progress}}" border-radius="10" show-info="true" stroke-width="4" color="#00a7e2"></progress>
自己用个变量记录上次setData时间,间隔100ms更新一次setData
有时候下载得快节流函数就不好用了..