摘要: 1.在父组件中绑定state值,传给子组件, 2.当父组件点击事件时,改变state值 3.子组件用componentWillReceiveProps()接收变化的props, 4.子组件执行父组件的回调函数进行接收值 阅读全文
posted @ 2020-03-15 14:17 whhhd 阅读(131) 评论(0) 推荐(0) 编辑
摘要: class Counter extends React.Component{ constructor(props,context) { super(props,context) this.state={ hou:0, second:0, minutes:0, strikes:0, } this.ti 阅读全文
posted @ 2020-03-15 14:14 whhhd 阅读(577) 评论(0) 推荐(0) 编辑
摘要: 1.直接在子组件中使用(不推荐) class child extends component{ render( <div>{this.props.value}</div> ) } 2.自己在构造函数中初始化一个值,在将 status 通过 componentWillReceiveProps 生命周期 阅读全文
posted @ 2020-03-15 10:13 whhhd 阅读(3782) 评论(0) 推荐(0) 编辑