IE11 에서 es6와 Promise까지 지원하고 싶다.

 

webpack 쓰면 되는거 알겠는데 그냥 간단히 빨리 지원하고싶다.

<!DOCTYPE html>
<html lang='en'>
<head>
  <meta charset='UTF-8'>
  <title>Title</title>
</head>
<body>

</body>
<script src="https://cdnjs.cloudflare.com/ajax/libs/babel-core/5.8.34/browser.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/babel-polyfill/7.12.1/polyfill.js"></script>

<script type="text/babel">
  alert(`dd`);

  function resolveAfter2Seconds() {
    return new Promise(resolve => {
      setTimeout(() => {
        resolve('resolved');
      }, 1000);
    });
  }

  async function asyncCall() {
    console.log('calling');
    const result = await resolveAfter2Seconds();
    alert(result);
  }

  asyncCall();
</script>
</html>

1. html 파일에 babel, polyfill cdn을 넣는다.

2. es6 문법과 Promise 지원 확인한다.

 

IE11 쓰면 벌금 메겼으면 좋겠다.

 

'JS' 카테고리의 다른 글

javascript 비동기 재귀 함수  (0) 2020.09.28
Promise 자바스크립트(js)  (0) 2019.10.18
loading button 쉽게 만들기(with js)  (0) 2019.10.15
js 화살표함수(arrow function)  (0) 2019.10.14
JS prototype(프로토타입)  (0) 2019.09.25

+ Recent posts