Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
440 views
in Technique[技术] by (71.8m points)

javascript - Template literals syntax is not working in IE11

The back-tick character is not recognized as a Valid Character in IE11 when using the "use strict" directive while it works in other browsers, such as Chrome.

What is the interpretation of this behavior taking into consideration that IE11 is still widely used even among Windows 10 users??

        "use strict";

        function doIt() {
          let tt;
          tt = 50;
          alert(`${tt}`);
          alert("test");
        }
       doIt();
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

If you look at the ECMAScript 6 compatibility table, you'll see that template literals are not supported by IE11. The "use strict"; statement doesn't really change anything, because before it is determined whether a code is in strict mode, it has to be parsed first, but it can't be parsed, because you're using syntax that the parser doesn't recognize.

If you want your code to work in IE11, you should transpile it with Babel.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...