首页 > 其他 > 详细

react 生命周期子父件传值

时间:2020-08-29 00:02:21      阅读:96      评论:0      收藏:0      [点我收藏+]
 componentWillReceiveProps(nextProps) {
    const { testValues } = this.props;
    const { pageSize } = this.state;
    if (nextProps.testValues !== testValues) {
      this.getQuery(nextProps.testValues, 1, pageSize);
    }
  }

父调用子组件的方法:可采用生命周期componentWillReceiveProps判断父组件的值是否变化来在子组件中调用子的方法。

react 生命周期子父件传值

原文:https://www.cnblogs.com/lipu12281/p/13580336.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!