Promise 链式操作

2021-07-05  本文已影响0人  弹力盒
const x = [
  20, 40, 60, 80, 100
]

let count = 0

const dom = $('.move')

const moveFun = (left) => {
  return new Promise((resolve) => {
    dom.animate({ left }, 1000, 'linear', () => {
      count++
      resolve()
    })
  })
}

moveFun(100)
  .then(() => moveFun(500))
  .then(() => moveFun(200))
  .then(() => moveFun(100))
  .then(() => moveFun(566))
  .then(() => moveFun(1000))
  .then(() => moveFun(100))

上一篇 下一篇

猜你喜欢

热点阅读