h***@163.com
h***@163.com
  • 发布:2021-05-26 15:55
  • 更新:2021-05-28 10:02
  • 阅读:529

取消上一次请求

分类:uni-app

请求频繁的时候,怎么取消上一次请求呢?

2021-05-26 15:55 负责人:无 分享
已邀请:
luch

luch

1

let task = null  
function req  () {  
if (task) {  

task.abort()  
}  
task = uni.request()  

}  

setInterval(() => {  
req  ()  

}, 1000)

2

推荐

function req  () {  
uni.request().then(res => {  

if (code === 200) {  
setTimeout(() => {  
req()  
}, 1000)  

}  

})  

}  

该问题目前已经被锁定, 无法添加新回复