实现 promise 失办后自动重试
发布时间
阅读量:
阅读量
[js] 写一个方法实现promise失败后自动重试
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body>
</body>
</html>
<script>
Promise.retry = (fun, limit = 5) => {
return new Promise((resolve, reject) => {
let __num = 1;
let __run = () => {
fun()
.then(res => {
resolve(re
全部评论 (0)
还没有任何评论哟~
