Front End Engineer -01-02- Stage 2: Componentization and mobile WebApp Development – Part 1

Promise- first know Promise 1, learn what Promise instance method Promise (video resources VX (cmL46679910)) constructor method Promise notes and applications 2, Promise is what the basic use of Promise then()

<script> const move = (el, { x = 0, y = 0 } = {}, end = () => {}) => { el.style.transform = `translate3d(${x}px, ${y}px, 0)`; el.addEventListener( 'transitionend', () => { end(); }, false ); }; (video resource vx (cmL46679910)) const boxEl = document.getelementById ('box'); Const movePr (vx (cmL46679910)) omise = (el, point) => {return new Promise(resolve => {el, point, () => { resolve(); }); }); }; document.addEventListener( 'click', () => { movePromise(boxEl, { x: 150 }) .then(() => { return movePromise(boxEl, { x: 0, y: 0 }); }) .then(() => { return movePromise(boxEl, { x: 150, y: 150 }); }) .then(() => { return movePromise(boxEl, { y: 150 }); }); }, false ); </script>Copy the code

The instance method catch() for Promise

Promise.race() promise.allSettled () Promise (vx (cmL46679910)) Promise Reject executes the code