路由跳转后,因为还是同一个组件,不会触发componentDidMount,所以我在componentWillReceiveProps里进行处理了。
1 回答
四季花海
TA贡献1811条经验 获得超5个赞
先把componentWillReceiveProps的生命周期搞清楚。componentWillReceiveProps方法中,要通过nextProps来改变state.你setState的那个值,与nextProps毛关系都没有,当然子组件不更新了。
另外,props也可以render,所以不需要componentWillReceiveProps,直接在render中,根据props实现就好了。
添加回答
举报
0/150
提交
取消
