React生命周期函数:
constructor(props){
super(props)
console.log('constructor-----------')
}
componentWillMount(){
console.log('componentWillMount 组件将要加载时触发')
}
render(){
console.log('render')
}
componentDidMount(){
console.log('componentDidMount 组件已经加载时触发s')
}
生命周期更新的时候
componentWillReceiveProps(){
console.log('你在父组件里面改变props传值的时候触发的:')
}
shouldComponentUpdate(){
console.log('组件是否更新')
return true (需要更新)
return false (不需要更新)
}
componentWillUpdate(){
console.log('组件将要更新')
}
componentDidUpdate(){
console.log('组件更新完成')
}
组件卸载的时候
componentWillUnmount(){
console.log('组件将要卸载的时候')
}