나는이 질문을 여러 번 물어 본다.하지만 여전히 내 머리를 잡지 못했다. 자바 스크립트 oop를 사용하고 있는데 부모 클래스 함수 this.returnResult
을 자식 클래스 함수 this.fullArr
에서 호출해야합니다.자식 클래스의 oop 호출 부모 함수
function parantCls(){
this.sCus = [];
this.aCus = [];
this.response;
this.returnResult = function(msg){
this.response = {
result : msg
};
return this;
}
}
function resonse(){
parantCls.apply(this, arguments);
this.fullArr = function(){
// call parent function
parantCls.prototype.returnResult(this,'setting customField should be array not ' + typeof this.sCus);
return this.response;
}
}
resonse.prototype = new parantCls();
왜 parantCls.prototype.returnResult(this,'setting customField should be array not ' + typeof this.sCus);
이 작동하지 않습니다. 메신저이
parantCls.prototype.returnResult.call(this,'setting customField should be array not ' + typeof this.sCus);
같은 call and apply
을 사용하지만 여전히 작동하지 않습니다. 문제가 무엇입니까
는 ('parantCls.prototype.returnResult.call (이는 ...') (근무해야 –
결과 : 스택 스 니펫을 사용하여 ** runnable ** [mcve]로 질문을 업데이트하십시오. ([[>] 도구 모음 버튼) –