JS__class 鍏ュ潙 chrome娴嬭瘯class 鐖跺瓙绫?缁ф壙鍏崇郴

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了JS__class 鍏ュ潙 chrome娴嬭瘯class 鐖跺瓙绫?缁ф壙鍏崇郴相关的知识,希望对你有一定的参考价值。

鏍囩锛?a href='http://www.mamicode.com/so/1/span' title='span'>span   struct   return   over   涓嶈兘   his   璋冪敤   ons   娴嬭瘯   

emmm...鐩存帴閫氳繃娴嬭瘯鏉ョ湅鐖跺瓙鍏崇郴鍚э細

class A{
    constructor(){//骞堕潪蹇呴』
        this.name="class_A";
        //console.log(this) //A {name: "class_A"} (鍙﹁捣涓€琛?B {name: "class_A"} //鐖剁被瀛愮被鍒嗗埆鎵ц浜嗕竴娆?/span>
    }
    static staticCallNameA(){
    return "name_A";
    }
    callNameA(){
    return "name_A";
    }
    static cover(){
    return "cover_A"
    }
}

class B extends A{
    constructor(){//瀛愮被鍙互涓嶅姞
    super();//瀛愮被蹇呴』鏈?/span>
    //console.log(this)//B {name: "class_A"} //浼氱洿鎺ユ墦鍗?/span>
    }
    static staticCallNameB(){
    return "nameB";
    }
    callNameB(){
    return "name_B";
    }
    static cover(){
    return "cover_B"
    }
}
console.log(A.name,B.name) //A B //(绫诲悕)
console.log(A.staticCallNameA(),B.staticCallNameA()) //static瀛愮被缁ф壙鐖剁被
console.log(A.cover(),B.cover()) //cover_A cover_B //鍏堣瀛愮被鍐嶈鐖剁被
console.log(A.staticCallNameB) //undefined //鐖剁被涓嶅叿澶囧瓙绫荤壒鏈夊嚱鏁?/span>
console.log(A.callNameA,B.callNameA) //undefined undefined //闈瀞tatic鏂规硶绫讳笉鑳界洿鎺ヨ皟鐢?/span>

let a=new A(),b=new B; //鍔犱笉鍔犳嫭鍙锋晥鏋滀竴鏍?/span>
console.log(a.name); //class_A
console.log(a.name,b.name) //class_A class_A
console.log(a.callNameA(),a.callNameB,b.callNameB(),b.callNameA()) //name_A undefined name_B name_A //璇存槑缁ф壙鍏崇郴鍚屼笂

娆㈣繋鍚勪綅澶х鎸囩偣...

以上是关于JS__class 鍏ュ潙 chrome娴嬭瘯class 鐖跺瓙绫?缁ф壙鍏崇郴的主要内容,如果未能解决你的问题,请参考以下文章

ES6 class setTimeout promise async/await 娴嬭瘯Demo

iOS鎬ц兘娴嬭瘯瀹炴垬-instruments

鎬ц兘娴嬭瘯涔嬫柊涓€浠f湇鍔″櫒鎬ц兘娴嬭瘯宸ュ叿Gatling

鑺墖娴嬭瘯

python娴嬭瘯鏂█