子類的static方法中用父類的方法會報錯

class base{
    show(){
        console.log('顯示')    
    }
}
class child extends base{
    static init(){
        this.show()
    }
}

this.show()會報錯,找不到show這個方法

原因:還不知道。。

解決:把static先刪掉了

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章