jquery class inheritance

后端 未结 6 2024
清歌不尽
清歌不尽 2020-12-24 02:41
var A=function(){
};

$.extend(A.prototype, {
    init:function(){
        alert(\'A init\');
    }
});
var B=function(){

};

$.extend(B.prototype,A.prototype,{
            


        
6条回答
  •  伪装坚强ぢ
    2020-12-24 03:12

    How to invoke parent's methods:

    var B=function(){
        A.call(this);
    };
    
    $.extend(B.prototype,A.prototype,{
            init:function(){
                    A.prototype.init.call(this);
                    alert('B init');
            }
    });
    

提交回复
热议问题