學習-react 子組件改變父組件中的state值


https://www.jianshu.com/p/ac6300b7aa07

react 子組件改變父組件的state值:通過將父組件中的方法傳給子組件,(在方法中改變state值)

父組件:
    handleE = () => {
        let newType = this.state.type;
        newType +=1
        this.setState({
            type:newType
        })
    }
 <Edit
                        info={Unit}
                        honor={honor}
                        handleClose={this.handleClose}
                        changeData={() => this.FetchList(this.state.formValues)}
                        groupOptions={groupOptions}
                        handleE={this.handleE}
                    />
子組件:
 <button onClick={this.props.handleE}>diandian</button>

 context 參考:https://www.jianshu.com/p/65b348bf86ad

js判斷小數點后邊有幾位數
var n=3.143423423;
alert(n.toString().split(".")[1].length);

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM