初始化 挂载 更新 卸载
componentwillMount(){} 将要挂在到页面时候
render(){} 组件挂载中
componentDidMount(){} 组件挂载完成的时刻
componentWillReceiveProps
//组件第一次存在于dom中,函数是不会被执行。如果已经存在于DOM中,函数才会被执行。
shouldComponentUpdate(nextProps,nextState){
//返回false就不执行了,true的话在render之前执行
}
请求数据之axios
componentDidMount(){axios.post('https://web-api.juejin.im/v3/web/wbbr/bgeda')
.then((res)=>{console.log('axios 获取数据成功'+JSON.stringify(res)})
.catch((error)=>{
console.log('axios 获取数据失败:'+error)})
}