Skip to content

Latest commit

 

History

History
28 lines (21 loc) · 516 Bytes

#5-不能摸的狗(一).md

File metadata and controls

28 lines (21 loc) · 516 Bytes

题目描述:

有一只狗,不允许别人摸它,一旦摸它就会叫,然后就跑了。

完成 Dog 组件,当用户点击的时候会执行自身的 barkrun 方法。


参考答案:

class Dog extends Component {
  bark () {
    console.log('bark')
    this.run();
  }
  
  run () {
    console.log('run')
  }
  
  render () {
    return (<div onClick={this.bark.bind(this)}>DOG</div>)
  }
}