不传参数时候 函数定义成箭头函数直接使用

render () {
        return (
            <div>
                <h4>请发表你的看法</h4>
                <div className ="flex">
                    <Add addItemFun={this.addItemFun}/>
                    <Lists commentList={this.state.commentList} deleItemFun ={this.deleItemFun} />
                </div>
            </div> 
        )
    }

 

传递参数的时候,函数仍然是定义成箭头函数

 render() {
        const {content,deleItemFun} = this.props;
        return (
            <div>
                <p>{content.userName}说:</p>
                <p>{content.comment}</p>
                <br/>
                <button onClick={()=>this.deleItem(content.id)}>删除</button>
            </div>
        )
    }

 

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-07-26
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-07-27
  • 2022-12-23
  • 2022-12-23
  • 2022-01-23
  • 2021-11-17
相关资源
相似解决方案