Babel transpiled code does not support static methods in IE11

安稳与你 提交于 2019-12-23 04:49:08

问题


Babel transpiled js works fine, but on IE11 the static inheritance seems not to work. Any idea?

class SuperClass {
    constructor () {}

    static test () {}
}

class Sub extends SuperClass {
    constructor () {
        super();
    }
}

Sub.test(); //Results in: "Object doesn't support property or method 'test'

回答1:


It seems that Babel does not handle the case, in fact in the inherits helper, if the Object.setPrototypeOf method is undefined, Babel simply attaches the super class to the __proto__ key.

I have managed this issue including this polyfill/workaround at the. At the moment, it seems to work fine, until the Babel team won't fix this behavior.



来源:https://stackoverflow.com/questions/34183086/babel-transpiled-code-does-not-support-static-methods-in-ie11

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!