Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

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

internet explorer - IE11 gives SCRIPT1002 error when defining class in javascript

I have some trouble with IE11 and a static javascript class I wrote.

The error I get is:

SCRIPT1002: Syntax error rgmui.box.js (6,1)

Which points to:

// ===========================================
// RGMUI BOX
// Static class

class RgMuiBox {
^

So I'm guessing I'm defining this class in the wrong way? What's the correct way of doing this?

I found a post on SO that seems to point out that the issue is ES5 vs ES6 - and I figure IE11 doesn't support ES6?

Just to be complete, this is what I have (simplified):

class RgMuiBox {
    static method1() {
    // .. code ..
    }
}

Thanks!

See Question&Answers more detail:os

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

1 Reply

0 votes
by (71.8m points)

Hate to reopen such an old issue, but it still shows up high in the results, so I'll add what I found out:

To reiterate what @Mikey and @REJH said, classes are not recognized by IE11.

That said, tools like Babel will allow you to translate classes into something that will run on IE11.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...