Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

setTimeout使用await需要配合Promise #8

Open
GoDotDotDot opened this issue Jan 2, 2018 · 0 comments
Open

setTimeout使用await需要配合Promise #8

GoDotDotDot opened this issue Jan 2, 2018 · 0 comments

Comments

@GoDotDotDot
Copy link

await setTimeout(async() => {

这样使用前端ajax就可以不用延迟获取截图

function sleep (ms) {
  return new Promise((resolve, reject) => {
    console.log('睡眠开始')
    setTimeout(() => {
      console.log('睡眠结束')
      resolve()
    }, ms)
  })
}
iJump = async (distance) => {
  await jumpGo(parseInt(distance * BOOM))
  await sleep(500)
  await fetchScreenCap()
  console.log('截图完成...')
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant