slow3G网络环境下,wx.request发起get请求会阻塞页面点击事件的问题?
微信开发工具模拟slow3G网络,点击按钮让count+1,利用防抖发起get请求,防抖触发后在点击按钮,事件会阻塞延迟执行。
plus() {
const { count } = this.data
this.setData({
count: count + 1
})
if (this.timer) {
clearTimeout(this.timer)
this.timer = null
}
this.timer = setTimeout(() => {
this.reqGetPhoto();
}, 300)
},
reqGetPhoto() {
wx.request({
url: 'https://cdn.segmentfault.com/r-baac7586/static/bg-219.7a1acf4f.svg',
method: 'GET',
success: (res) => {
console.log(res)
}
})
}