extends

作者: 基本密码宋 | 来源:发表于2017-10-31 18:01 被阅读8次
class Chef {


    constructor(food) {
        this.food = food;
        this.data;
    }

    cook() {
        console.log('我在做饭' + this.food);
    }

    set menu(data) {   //set方法
        this.data = data;
    }

    get menu() {     //get方法
        return this.data;
    }

    static show() {
        console.log("show")
    }


}


class ChefMySelf extends Chef {

    constructor(food) {
        super(food)
    }

}

let chefMySelf = new ChefMySelf('米饭');
chefMySelf.cook()








相关文章

网友评论

      本文标题:extends

      本文链接:https://www.haomeiwen.com/subject/btzbpxtx.html