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);