Solve the problem that vue cannot be used in ie

Installation configuration

(1) We can go to its release page ( click to jump ) to download babel.js or babel.min.js and reference it on the page.

1

<script src="babel.min.js"></script>


(2) You can also directly quote the address of the online version

1

<script src="https://unpkg.com/babel-standalone@6/babel.min.js"></script>

 

test case

(1) Here we still use the two new features of ES6 let and const as an example. Note: Although our ES6 script is also placed in the script tag, it must be marked with type="text/babel"

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

<!DOCTYPE html>

<html>

  <head>

    <meta charset="utf-8">

    <title>hangge.com</title>

    <script src="https://unpkg.com/babel-standalone@6/babel.min.js"></script>

    <script type="text/babel">

      for (let i=0; i<5; i++) {

        console.log('sm')

      }

      console.log(i) // Error: i is not defined

 

      const fix = {}

      fix.some = 'sm'

      console.log(fix.some) // sm

    </script>

  </head>

  <body>

  </body>

</html>


(2) Visit the page and you can see that the ES6 code has been automatically converted to ES5.

Original: JS - Detailed explanation of Babel use 1 (basic introduction, using babel-standalone to achieve ES6 online conversion)

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325845964&siteId=291194637