나는 기본 클래스를 확장하고 기본 클래스의 메서드를 재정의합니다. 하지만 그것을 호출하면 슈퍼 클래스 버전을 호출합니다. 방법을 어떻게 재정의합니까? 그러나 "이것은 : 슈퍼"인쇄 : 나는 그것을 인쇄 할React?에서 부모 클래스 메서드를 재정의하는 방법?
var Hello = React.createClass({
getName: function() { return "super" },
render: function() {
return <div>This is: {this.getName()}</div>;
}
});
class HelloChild extends Hello {
constructor(props) {
super(props);
console.log(this.getName());
}
getName()
{
return "Child";
}
};
는 "자식입니다"
https://jsbin.com/qizihe/edit?html,js,output – caub