1
에서 부모의 메소드를 호출하는 방법 : Uncaught TypeError: Cannot read property 'call' of undefined
나는 방법 pranet 전화를 시도하고이 오류 받고 있어요 아이
function Parent() {
this.parentFunction = function(){
console.log('parentFunction');
}
}
Parent.prototype.constructor = Parent;
function Child() {
Parent.call(this);
this.parentFunction = function() {
Parent.prototype.parentFunction.call(this);
console.log('parentFunction from child');
}
}
Child.prototype = Object.create(Parent.prototype);
Child.prototype.constructor = Child;
var child = new Child();
child.parentFunction();
대 :
는 "부모"생성자가 추가 "parentFunction는"당신이 참조를 저장할 수에 액세스하려면
. 그것은 작동합니다! 설명 해줘서 고마워. 나는 OOP 자바 스크립트에 새로운입니다. – user1561346