zoukankan      html  css  js  c++  java
  • reactjs踩坑记

    getFieldDecorator 提示错误 Warning: `getFieldDecorator` will override `value`, so please don't set `value` directly and use `setFieldsValue` to set it.
    原因getFieldDecorator方法包装后的组件会自动更新表单组件的value以及onChange事件无需再添加value值
    错误
    <Form.Item label="加密机">
              {getFieldDecorator('encryptorId', {
                rules: [{ required: true, message: '选择加密机标识!' }],
              })(
                <Select value={encryptorId}
                        onChange={this.onSelectChangeQuery} className={styles.EncryptorSelect}>
                  {eNames}
                </Select>,
              )}
            </Form.Item>
    正确
    <Form.Item label="加密机">
              {getFieldDecorator('encryptorId', {
                rules: [{ required: true, message: '选择加密机标识!' }],
              })(
                <Select 
                        onChange={this.onSelectChangeQuery} className={styles.EncryptorSelect}>
                  {eNames}
                </Select>,
              )}
            </Form.Item>
    

    1、render

    render(){
      return{
    
      }  
    }
    render必须加return,return里面只能有一个div(根元素)

    2、生命周期

    //加载之前
    componentWillMount(){
    
    }
    //加载之后
    componentDidMount(){
    
    }
    

    3、函数绑定方式

    <button onClick={this.handleAdd}></button>
    <button onClick={this.handleClick.bind(this)}></button>
    //使用bind
    handleClick(){
    this.setState({
    })
    }
    //不使用bind 必须使用箭头函数
    handleAdd=()=>{
    this.setState({
    })    
    }
    

      

  • 相关阅读:
    观察者模式
    工厂模式
    单例模式
    代理模式
    策略模式
    Ioc容器
    Spring概述
    02:入门
    01:背景
    编译原理感悟
  • 原文地址:https://www.cnblogs.com/iwen1992/p/12917033.html
Copyright © 2011-2022 走看看