问题描述
我在使用IE11和我编写的静态javascript类时遇到了一些麻烦。
I have some trouble with IE11 and a static javascript class I wrote.
我得到的错误是:
指向:
// ===========================================
// 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?
我在SO上发现了一个帖子,似乎指出问题是ES5 vs ES6 - 我认为IE11不支持ES6?
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 ..
}
}
谢谢!
推荐答案
讨厌重新打开这么老的问题,但它仍然显示在结果中,所以我将添加我发现的内容:
Hate to reopen such an old issue, but it still shows up high in the results, so I'll add what I found out:
重申@Mikey和@REJH所说的,类不是IE11认可。
To reiterate what @Mikey and @REJH said, classes are not recognized by IE11.
也就是说,像这样的工具将会允许您将类转换为可在IE11上运行的内容。
That said, tools like Babel will allow you to translate classes into something that will run on IE11.
这篇关于IE11在javascript中定义类时出现SCRIPT1002错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!