react ~1.生命周期函数


componentWillMount:function(){}//组件挂载到节点之前执行

componentDidMount:function(){}//节点被加载到指点节点之后执行

componentWillUnmount:function(){}//组件被删除之前执行,可用于执行释放内存,和停定时器等

componentWillUpdate//更新前

componentDidUpdate//通过render渲染到界面之后执行

shouldComponentUpdate:function(){
return true|false//如果返回true,react就会重新调用componentWillUpdate->render->界面重新渲染->componentDidUpdate
} //返回false,就没有然后了

this.setState({
//设置状态state,原state有同样属性就覆盖更新,原state没有,就加入到state中更新state
//当状态更新时,就会调用component,此时可以使用this.props传入其他父页面传入的数据,也可以获取路由传入的数据:this.props.location.state.传入的对象'{}'
})

转载于:https://www.cnblogs.com/sunshineForFuture/p/10342133.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值