0
class Point{

    static getName(){
        this.x = 3;
        console.log(Point.name)
    }

    getName(){
        console.log(this.x)
    }
}
class ColorPoint extends Point{
    constructor(){
        super();
        this.x = 2;
        super.x = 3;
        console.log(this.x)//这里输出3
    }
    m(){
        super.getName()
    }
}

babel转换过程的代码

var _set = function set(object, property, value, receiver) {
        var desc = Object.getOwnPropertyDescriptor(object, property);
        if (desc === undefined) {
            var parent = Object.getPrototypeOf(object);
            if (parent !== null) {
                set(parent, property, value, receiver);
            }
        } else if ("value" in desc && desc.writable) {
            desc.value = value;
        } else {
            var setter = desc.set;
            if (setter !== undefined) {
                setter.call(receiver, value);
            }
        }
        return value;
    };

    _set(ColorPoint.prototype.__proto__ ||     Object.getPrototypeOf(ColorPoint.prototype), "x", 3, _this);

但是通过babel构建过后,始终输出2。这是什么问题?

撰写答案