react学习笔记

  • 事件方法
三种方法:
    1 方法上写bind
    run () {
        alert(this.state.name);
    }
    <button onClick={this.run.bind(this)}></button>
    2. 在构造方法中写:
    constructor () {
        this.run = this.run.bind(this);
    }
    
    run () {
        alert(this.state.name);
    }
    <button onClick={this.run}></button>
    
    3. 第三种
    run=()=> {
        alert(this.state.name)
    }
    <button onClick={this.run}></button>
  • 获取表单的值
       vue中通过双向绑定,react相对比较麻烦:
1. 监听表单的改变时间
2. 在改变时间里获取表单输入的值
3. 把表单输入的值赋值给this.state中的对象

或者可以通过获取DOM节点方式获取:

1. 设置节点的refs属性
2. this.refs.xxxxx

value和defaultValue的关系

  • diff虚拟DOM算法

  • React生命周期函数

  • 需要总结React的技术亮点和缺点

posted @ 2018-12-01 14:33  boykait  阅读(104)  评论(0编辑  收藏  举报